# stormbreaker-prometheus

> SLO checks over a stormbreaker run's window, from Prometheus, across every region a service runs in: from a Prometheus of the app's own in each region or zone, a shared Prometheus per region, or a global view.

Source: https://stormbreaker.nimbusxr.us/next/references/packs/stormbreaker-prometheus/

SLO checks over a stormbreaker run's window, from Prometheus, across every region a service runs in: from a Prometheus of the app's own in each region or zone, a shared Prometheus per region, or a global view. Counters are summed across servers, and histogram buckets are merged before a quantile is interpolated: percentiles are never averaged. Checks poll until they hold or their patience runs out. Builds on stormbreaker-core (list it in axx-packs.yaml), whose run gives the window.

## Add it

List it in the project's `axx-packs.yaml`, with the packs it builds on:

```yaml title="axx-packs.yaml"
packs:
  - github.com/nimbusxr/stormbreaker/packs/core@v0.1.0
  - github.com/nimbusxr/stormbreaker/packs/prometheus@v0.1.0
```

## Parameter types

| Parameter | What it takes | Examples |
|---|---|---|
| `{prometheusService}` | the name of a Prometheus service the scenario registered | `parcels-metrics` |
| `{quantile}` | a quantile, like p99 or p99.9 | `p50`, `p99`, `p99.9` |

## Steps

### `stormbreaker.prometheus.service`

```gherkin
Given the {word} prometheus service with the following properties:
```

Register a Prometheus service: one logical service, and the Prometheus servers that hold its metrics, in every region it runs in. The first one registered in a scenario is the default.

| Property | Takes | Default |
|---|---|---|
| `url` (required) | the Prometheus servers whose series are summed, comma-separated: one per region, per app per region or zone, or a single global view; replicas of one server (an HA pair) separated by `\|`, the first that answers asked; it can use `${env:…}` |  |
| `selector` | label matchers that pick the service's series out of a Prometheus that holds other services' too, like `app="parcels"` | every series |
| `minimum-window` | the shortest window a check judges, the scrape interval or more, like `30s` | 30s |

```gherkin
Given the parcels-metrics prometheus service with the following properties:
  | url | http://prom-east:9090,http://prom-west:9090 |
Given the parcels-metrics prometheus service with the following properties:
  | url      | http://parcels-prom-0.eu-1:9090\|http://parcels-prom-1.eu-1:9090,http://parcels-prom-0.eu-2:9090\|http://parcels-prom-1.eu-2:9090 |
Given the parcels-metrics prometheus service with the following properties:
  | url      | http://thanos-query:9090 |
  | selector | app="parcels"           |
```

### `stormbreaker.prometheus.quantile`

```gherkin
Then within {duration} the {quantile} of {word} over the run[[ on {prometheusService}]] is at most {float} seconds
```

Check a latency quantile of a histogram (its name without `_bucket`) over the run's window. The servers' buckets are summed, then the quantile is interpolated as `histogram_quantile` does.

```gherkin
Then within 30s the p99 of http_server_requests_seconds over the run is at most 0.5 seconds
```

### `stormbreaker.prometheus.increase`

```gherkin
Then within {duration} the increase of {word} over the run[[ on {prometheusService}]] is at least {float}
```

Check how much a counter increased over the run's window, summed across the servers.

```gherkin
Then within 30s the increase of http_server_requests_seconds_count over the run is at least 45
```
