google / slo-generator

SLO Generator computes SLIs, SLOs, Error Budgets and Burn Rates from supported backends, then exports an SLO report to supported targets.
Apache License 2.0
491 stars 79 forks source link

SLO Generator

test build deploy PyPI version Downloads

slo-generator is a tool to compute and export Service Level Objectives (SLOs), Error Budgets and Burn Rates, using configurations written in YAML (or JSON) format.

IMPORTANT NOTE: the following content is the slo-generator v2 documentation. The v1 documentation is available here, and instructions to migrate to v2 are available here.

Table of contents

Description

The slo-generator runs backend queries computing Service Level Indicators, compares them with the Service Level Objectives defined and generates a report by computing important metrics:

The Error Budget Burn Rate is often used for alerting on SLOs, as it demonstrates in practice to be more reliable and stable than alerting directly on metrics or on SLI > SLO thresholds.

Local usage

Requirements

Installation

slo-generator is a Python library published on PyPI. To install it, run:

pip3 install slo-generator

Notes:

CLI usage

To compute an SLO report using the CLI, run:

slo-generator compute -f <SLO_CONFIG_PATH> -c <SHARED_CONFIG_PATH> --export

where:

Use slo-generator compute --help to list all available arguments.

API usage

On top of the CLI, the slo-generator can also be run as an API using the Cloud Functions Framework SDK (Flask) using the api subcommand:

slo-generator api --config <SHARED_CONFIG_PATH>

where:

Once the API is up-and-running, you can make HTTP POST requests with your SLO configurations (YAML or JSON) in the request body:

curl -X POST -H "Content-Type: text/x-yaml" --data-binary @slo.yaml localhost:8080 # yaml SLO config
curl -X POST -H "Content-Type: application/json" -d @slo.json localhost:8080 # json SLO config

To read more about the API and advanced usage, see docs/shared/api.md.

Configuration

The slo-generator requires two configuration files to run, an SLO configuration file, describing your SLO, and the Shared configuration file (common configuration for all SLOs).

SLO configuration

The SLO configuration (JSON or YAML) is following the Kubernetes format and is composed of the following fields:

Note: you can use environment variables in your SLO configs by using ${MY_ENV_VAR} syntax to avoid having sensitive data in version control. Environment variables will be replaced automatically at run time.

→ See example SLO configuration.

Shared configuration

The shared configuration (JSON or YAML) configures the slo-generator and acts as a shared config for all SLO configs. It is composed of the following fields:

→ See example Shared configuration.

More documentation

To go further with the SLO Generator, you can read:

Build an SLO achievements report with BigQuery and DataStudio

Deploy the SLO Generator in Cloud Run

Deploy the SLO Generator in Kubernetes (Alpha)

Deploy the SLO Generator in a CloudBuild pipeline

DEPRECATED: Deploy the SLO Generator on Google Cloud Functions (Terraform)

Contribute to the SLO Generator