Interview Prep/Monitoring & Observability/Observability as Code, Security & Vendor Choices

What does a CI pipeline for Prometheus rules look like?

IntermediateProductionObservability as Code, Security & Vendor Choices
Answer
  1. promtool check rules rules/*.yaml for syntax (extract the spec from PrometheusRule objects first, or lint with pint).
  2. promtool test rules tests/*.yaml with unit tests that feed synthetic series and assert which alerts fire and with which labels.
  3. pint ci (Cloudflare) against a live Prometheus to catch rules referencing metrics that do not exist, missing runbook_url, or rate over gauges.
  4. Merge, then GitOps (Argo CD / Flux) applies the CRDs.
tests:
  - interval: 1m
    input_series:
      - series: 'job:http_errors:ratio_rate5m{job="api"}'
        values: '0.2x15'
    alert_rule_test:
      - eval_time: 10m
        alertname: APIHighErrorRate
        exp_alerts: [{ exp_labels: { severity: critical, job: api } }]
All Monitoring & Observability questions

More on Observability as Code, Security & Vendor Choices