Generate Prometheus alerting & recording rules for SLOs with CUE.
Highly experimental!
First, a service must be defined with associated SLOs.
import (
"github.com/cbrgm/slo-cue/schema"
)
services: schema.#ServiceDefinition
services: "foo_service": [
{
name: "read"
errorsQuery: "sum(rate(promhttp_metric_handler_requests_total{namespace='default',job='fooapp',code=~'5..'}[$__range]))"
totalQuery: "sum(rate(promhttp_metric_handler_requests_total{namespace='default',job='fooapp'}[$__range]))"
threshold: 0.999
}
]
This service definition must be saved in the tools
folder (for example as foo_service.cue
).
Dump the Prometheus Alerting & Recording Rules as JSON.
cd tools && cue dumpjson
or as yaml
cd tools && cue dump
This project was inspired by
Literature:
- Implementing Service Level Objectives; Alex Hidalgo; O'Reilly Media, Inc., 2020; ISBN: 9781492076810
- Google SRE: Alerting on SLOs; Steven Thurgood et al.
Feel free to submit changes! See the Contributing Guide. This project is open-source and is developed under the terms of the Apache 2.0 License.