<commit_before># SLO Generator

`slo-generator` is a tool to compute and export **Service Level Objectives** ([SLOs](https://landing.google.com/sre/sre-book/chapters/service-level-objectives/)),
**Error Budgets** and **Burn Rates**, using policies written in JSON or YAML format.

## Description
`slo-generator` will query metrics backend and compute the following metrics:

* **Service Level Objective** defined as `SLO (%) = GOOD_EVENTS / VALID_EVENTS`
* **Error Budget** defined as `ERROR_BUDGET = 100 - SLO (%)`
* **Burn Rate** defined as `BURN_RATE = ERROR_BUDGET / ERROR_BUDGET_TARGET`

## Local usage

**Requirements**

* Python 3
* gcloud SDK installed

**Installation**

`slo-generator` is published on PyPI. To install it, run:

```sh
pip3 install slo-generator
```

**Run the `slo-generator`**

```
slo-generator --slo-config=<SLO_CONFIG> --error-budget-policy=<ERROR_BUDGET_POLICY>
```
  * `<SLO_CONFIG>` is the [SLO config](#slo_configuration) JSON or YAML file.

  * `<ERROR_BUDGET_POLICY>` is the [Error Budget Policy](#error_budget_policy) JSON or YAML file.

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


## Configuration

The `slo-generator` requires two configuration files to run, the **SLO configuration** file and the **Error budget policy** file.

**SLO configuration**

The **SLO configuration** (JSON or YAML) is composed of the following fields:

* **SLO metadata**:
  * `slo_name`: Name of this SLO.
  * `slo_description`: Description of this SLO.
  * `slo_target`: SLO target (between 0 and 1).
  * `service_name`: Name of the monitored service.
  * `feature_name`: Name of the monitored subsystem.


* **SLI configuration**:
  * `backend`: Specific documentation and examples are available for each supported backends:
    * [Stackdriver Monitoring](docs/stackdriver.md)
    * [Prometheus](docs/prometheus.md)


- **Exporter configuration**:
  * `exporters`: A list of exporters to export results to. Specific documentation is available for each supported exporters:
      * [Cloud Pub/Sub](docs/pubsub.md) to stream SLO reports.
      * [BigQuery](docs/bigquery.md) to export SLO reports to BigQuery for historical analysis and DataStudio reporting.
      * [Stackdriver Monitoring](docs/stackdriver.md#how-to-use-stackdriver-exporter) to export the `error_budget_burn_rate` metric to Stackdriver Monitoring.
      * [Prometheus](docs/prometheus.md#how-to-use-prometheus-exporter) to export the `error_budget_burn_rate` metric to Prometheus.<commit_msg>Fix linking<commit_after># SLO Generator

`slo-generator` is a tool to compute and export **Service Level Objectives** ([SLOs](https://landing.google.com/sre/sre-book/chapters/service-level-objectives/)),
**Error Budgets** and **Burn Rates**, using policies written in JSON or YAML format.

## Description
`slo-generator` will query metrics backend and compute the following metrics:

* **Service Level Objective** defined as `SLO (%) = GOOD_EVENTS / VALID_EVENTS`
* **Error Budget** defined as `ERROR_BUDGET = 100 - SLO (%)`
* **Burn Rate** defined as `BURN_RATE = ERROR_BUDGET / ERROR_BUDGET_TARGET`

## Local usage

**Requirements**

* Python 3
* gcloud SDK installed

**Installation**

`slo-generator` is published on PyPI. To install it, run:

```sh
pip3 install slo-generator
```

**Run the `slo-generator`**

```
slo-generator --slo-config=<SLO_CONFIG> --error-budget-policy=<ERROR_BUDGET_POLICY>
```
  * `<SLO_CONFIG>` is the [SLO config](#slo_configuration) JSON or YAML file.

  * `<ERROR_BUDGET_POLICY>` is the [Error Budget Policy](#error_budget_policy) JSON or YAML file.

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


## Configuration

The `slo-generator` requires two configuration files to run, the **SLO configuration** file and the **Error budget policy** file.

**SLO configuration**

The **SLO configuration** (JSON or YAML) is composed of the following fields:

* **SLO metadata**:
  * `slo_name`: Name of this SLO.
  * `slo_description`: Description of this SLO.
  * `slo_target`: SLO target (between 0 and 1).
  * `service_name`: Name of the monitored service.
  * `feature_name`: Name of the monitored subsystem.


* **SLI configuration**:
  * `backend`: Specific documentation and examples are available for each supported backends:
    * [Stackdriver Monitoring](docs/stackdriver.md)
    * [Prometheus](docs/prometheus.md)


- **Exporter configuration**:
  * `exporters`: A list of exporters to export results to. Specific documentation is available for each supported exporters:
      * [Cloud Pub/Sub](docs/pubsub.md) to stream SLO reports.
      * [BigQuery](docs/bigquery.md) to export SLO reports to BigQuery for historical analysis and DataStudio reporting.
      * [Stackdriver Monitoring](docs/stackdriver.md#how-to-use-the-stackdriver-exporter) to export the `error_budget_burn_rate` metric to Stackdriver Monitoring.
      * [Prometheus](docs/prometheus.md#how-to-use-the-prometheus-exporter) to export the `error_budget_burn_rate` metric to Prometheus.
{'fraction_non_alphanumeric': 0.12150279776179057, 'fraction_numerical': 0.002797761790567546, 'mean_word_length': 4.779445727482679, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4528296', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1496, 'n_words': 504}