Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update docs and samples with all backends #283

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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