Skip to content

Commit

Permalink
docs: update docs and samples with all backends (#283)
Browse files Browse the repository at this point in the history
* add `cloud_monitoring_mql` backend section to sample config

* update docs with missing backends
  • Loading branch information
lvaylet authored Oct 27, 2022
1 parent 32e52e8 commit 61f2f32
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 61 deletions.
176 changes: 115 additions & 61 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,152 @@
# SLO Library

This folder is an SLO library to facilitate writing new SLOs by starting from
already written SLO configurations.

All samples are classified into a folder named after their respective backend
or exporter class.

Each sample contains environmental variables that should be set prior to
running it.

## Environmental variables

The following is listing all environmental variables found in the SLO configs,
per backend:

`cloud_monitoring/`:
- `WORKSPACE_PROJECT_ID`: Cloud Monitoring host project id.
- `LOG_METRIC_NAME`: Cloud Logging log-based metric name.
- `GAE_PROJECT_ID`: Google App Engine application project id.
- `GAE_MODULE_ID`: Google App Engine application module id.
- `PUBSUB_PROJECT_ID`: Pub/Sub project id.
- `PUBSUB_TOPIC_NAME`: Pub/Sub topic name.

`cloud_service_monitoring/`:
- `WORKSPACE_PROJECT_ID`: Cloud Monitoring host project id.
- `LOG_METRIC_NAME`: Cloud Logging log-based metric name.
- `GAE_PROJECT_ID`: Google App Engine application project id.
- `GAE_MODULE_ID`: Google App Engine application module id.
- `PUBSUB_PROJECT_ID`: Pub/Sub project id.
- `PUBSUB_TOPIC_NAME`: Pub/Sub topic name.
- `GKE_PROJECT_ID`: GKE project id.
- `GKE_LOCATION`: GKE location.
- `GKE_CLUSTER_NAME`: GKE cluster name.
- `GKE_SERVICE_NAMESPACE`: GKE service namespace.
- `GKE_SERVICE_NAME`: GKE service name.

`elasticsearch/`:
- `ELASTICSEARCH_URL`: ElasticSearch instance URL.

`prometheus/`:
- `PROMETHEUS_URL`: Prometheus instance URL.
- `PROMETHEUS_PUSHGATEWAY_URL`: Prometheus Pushgateway instance URL.

You can either set those variables for the backends you want to try, or set all
of those in an `.env` file and then `source` it. Note that the actual GCP resources
you're pointing to need to exist.
This folder is an SLO library to facilitate writing new SLOs by starting from already written SLO configurations.

All samples are classified within folders named after their respective backend or exporter class.

Each sample references environment variables that must be set prior to running it.

## Environment variables

The following is listing all environment variables found in the SLO configs, per backend:

You can either set those variables for the backends you want to try, or set all of those in an `.env` file and then `source` it. Note that the actual GCP resources you're pointing to need to exist.

### `cloud_monitoring`

| Environment variable | Description |
| --- | --- |
| `WORKSPACE_PROJECT_ID` | Cloud Monitoring host project ID |
| `LOG_METRIC_NAME` | Cloud Logging log-based metric name |
| `GAE_PROJECT_ID` | Google App Engine application project ID |
| `GAE_MODULE_ID` | Google App Engine application module ID |
| `PUBSUB_PROJECT_ID` | Pub/Sub project ID |
| `PUBSUB_TOPIC_NAME` | Pub/Sub topic name |

### `cloud_monitoring_mql`

| Environment variable | Description |
| --- | --- |
| `WORKSPACE_PROJECT_ID` | Cloud Monitoring host project ID |
| `LOG_METRIC_NAME` | Cloud Logging log-based metric name |
| `GAE_PROJECT_ID` | Google App Engine application project ID |
| `GAE_MODULE_ID` | Google App Engine application module ID |
| `PUBSUB_PROJECT_ID` | Pub/Sub project ID |
| `PUBSUB_TOPIC_NAME` | Pub/Sub topic name |

### `cloud_service_monitoring`

| Environment variable | Description |
| --- | --- |
| `WORKSPACE_PROJECT_ID` | Cloud Monitoring host project ID |
| `LOG_METRIC_NAME` | Cloud Logging log-based metric name |
| `GAE_PROJECT_ID` | Google App Engine application project ID |
| `GAE_MODULE_ID` | Google App Engine application module ID |
| `PUBSUB_PROJECT_ID` | Pub/Sub project ID |
| `PUBSUB_TOPIC_NAME` | Pub/Sub topic name |
| `GKE_PROJECT_ID` | GKE project ID |
| `GKE_LOCATION` | GKE location |
| `GKE_CLUSTER_NAME` | GKE cluster name |
| `GKE_SERVICE_NAMESPACE` | GKE service namespace |
| `GKE_SERVICE_NAME` | GKE service name |

### `datadog`

| Environment variable | Description |
| --- | --- |
| `DATADOG_API_KEY` | Datadog API key |
| `DATADOG_APP_KEY` | Datadog APP key |

### `dynatrace`

| Environment variable | Description |
| --- | --- |
| `DYNATRACE_API_URL` | Dynatrace API URL |
| `DYNATRACE_API_TOKEN` | Dynatrace API token |

### `elasticsearch`

| Environment variable | Description |
| --- | --- |
| `ELASTICSEARCH_URL` | ElasticSearch instance URL |

### `prometheus`

| Environment variable | Description |
| --- | --- |
| `PROMETHEUS_URL` | Prometheus instance URL |
| `PROMETHEUS_PUSHGATEWAY_URL` | Prometheus Pushgateway instance URL |

## Running the samples

To run one sample:
```

```sh
slo-generator -f samples/cloud_monitoring/<filename>.yaml
```

To run all the samples for a backend:

```
```sh
slo-generator -f samples/<backend> -b samples/<error_budget_policy>
```

*where:*
* `<backend>` is the backend name (lowercase)
* `<error_budget_policy>` is the path to the error budget policy YAML file.

***Note:*** *if you want to enable the exporters as well, you can add the
`--export` flag.*
- `<backend>` is the backend name (lowercase)
- `<error_budget_policy>` is the path to the error budget policy YAML file.

***Note:*** *if you want to enable the exporters as well, you can add the `--export` flag.*

### Examples

##### Cloud Monitoring
```
#### Cloud Monitoring (MQF)

```sh
slo-generator -f samples/cloud_monitoring -b error_budget_policy.yaml
```

##### Cloud Service Monitoring
#### Cloud Monitoring (MQL)

```sh
slo-generator -f samples/cloud_monitoring_mql -b error_budget_policy.yaml
```

#### Cloud Service Monitoring

```sh
slo-generator -f samples/cloud_service_monitoring -b error_budget_policy_ssm.yaml
```

***Note:*** *the Error Budget Policy is different for this backend, because it only
supports steps where the `window` is a multiple of 24 hours.*
***Note:*** *the Error Budget Policy is different for this backend, because it only supports steps where `window` is a multiple of 24 hours.*

##### Prometheus
```
slo-generator -f samples/prometheus -b error_budget_policy.yaml
#### Datadog

```sh
slo-generator -f samples/datadog -b error_budget_policy.yaml
```

##### Elasticsearch
#### Dynatrace

```sh
slo-generator -f samples/dynatrace -b error_budget_policy.yaml
```

#### Elasticsearch

```sh
slo-generator -f samples/elasticsearch -b error_budget_policy.yaml
```

##### Custom Class
#### Prometheus

```sh
slo-generator -f samples/prometheus -b error_budget_policy.yaml
```

#### Custom Class

```sh
cd samples/
slo-generator -f custom -b error_budget_policy.yaml -e
```
2 changes: 2 additions & 0 deletions samples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ default_exporters: [cloudevent]
backends:
cloud_monitoring:
project_id: ${STACKDRIVER_HOST_PROJECT_ID}
cloud_monitoring_mql:
project_id: ${STACKDRIVER_HOST_PROJECT_ID}
cloud_service_monitoring:
project_id: ${STACKDRIVER_HOST_PROJECT_ID}
samples.custom.custom_backend.CustomBackend: {}
Expand Down

0 comments on commit 61f2f32

Please sign in to comment.