Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Automation & toolingMixed 22 series

Observability as code

Observability as code is not a dashboard committed to git. It is the ability to rebuild every signal from the repository.

Quick reference

Dashboards, alerts and pipelines that live in the repository.

  1. Review the signal — Rules, dashboards and collector config in the same pull request as the code.
  2. Test the rules — promtool check and test, with synthetic series and the page you expect.
  3. Provision the view — Dashboards from files or Terraform, never from a UI session.
  4. Own the pipeline — service.name, team and runbook on every artefact you ship.

In one line: Signals with owners. Observability you can rebuild is observability you can trust.

Start this week:

  • Move one alert rule into the repository this week.
  • Run promtool test rules on it before the next deploy.
  • Delete one dashboard nobody has opened this quarter.

Explained

Rules. An alert is a query with a promise, so it needs a test. promtool check validates the syntax and the PromQL; promtool test rules runs the query against synthetic series and asserts which alerts fire. The runbook link sits in the annotation, where on-call will read it.

Dashboards. Grafana provisioning reads files at start-up, and the Terraform Grafana provider manages dashboards through the API. A hand edit is a change the next deploy overwrites: a polite way of saying it never happened.

Pipelines. The collector config is a file with receivers, processors, exporters and pipelines. otelcol validate catches the typo before it becomes a silent drop, and service.name is what makes a trace findable.

Ownership. service, team, runbook and severity on every artefact. An alert without a team pages nobody, and a dashboard without an owner is a panel nobody deletes.

Checklist

Run it before the first on-call shift and after every service change. A line that cannot be answered is the next ticket.

Artefacts

  • Alert rules are in the repository and reviewed.
  • Dashboards are provisioned, not hand-edited.
  • Collector config is versioned with the services.

Checks

  • promtool check and test run in CI.
  • otelcol validate runs before deploy.
  • Every rule has an owner and a runbook link.

Delivery

  • The same commit ships code and telemetry.
  • Applying from a laptop is not a supported path.
  • A rollback restores rules and dashboards together.

Lifecycle

  • Retired services lose their rules in the same pull request.
  • SLOs are generated, not copied.
  • A quarterly review deletes what nobody reads.

The field guide

The full guide of the PDF (P1059), page by page.

Signals you can review (the shift)

A dashboard built by hand at 2 am is a rumour with a graph. Observability as code puts the signal definition in the same review as the service.

The test is simple: clone the repository, apply it to an empty project, and get the same alerts and the same dashboards. If a step needs a click, it is not code yet.

  • Metrics, alerts, dashboards and sampling rules live next to the service.
  • Every rule has an owner, a runbook link and a severity.
  • Changes arrive by pull request, with the diff visible.
  • The same commit deploys the service and its telemetry.
ArtefactWhere it lives
Alert rulesrules/*.yml, loaded by Prometheus
Dashboardsprovisioning JSON or Terraform
Collector configotelcol.yaml in the repo
SLOsslo.yaml, generated into rules

The empty project test Apply the repository to a new environment and see whether the alerts appear. A README that says click three times is not a deployment.

If rebuilding the dashboard needs a person who remembers the clicks, the dashboard is not code.

Alerts are code, so test them (rules)

An alert rule is a query with a promise attached. Both parts need a test, and Prometheus ships the tool.

Check, then test

promtool check config prometheus.yml
promtool check rules rules/api.yml
promtool test rules tests/api-rules.yml

check validates the syntax and the PromQL. test runs the rule against synthetic series and asserts which alerts fire, which is the only way to know that a threshold still matches the traffic.

  • Name the alert after the symptom, not the cause.
  • Put the runbook URL in the annotations, next to the summary.
  • Give the rule a for window long enough to survive a scrape.
  • Delete the rule with the service, in the same pull request.

A test file is documentation The test cases show the expected traffic and the expected page, which is more than most runbooks say.

An untested alert rule is a query that may fire, and a promise nobody checked.

Provision the view, do not paint it (dashboards)

A dashboard is a JSON document with a version. Treat it like any other artefact: store it, review it, deploy it.

Grafana provisioning reads files at start-up, and the Terraform Grafana provider manages dashboards through the API. Either way, the dashboard exists before someone opens the UI, and a hand edit is a change that will be overwritten.

A provisioned dashboard path

apiVersion: 1
providers:
  - name: acme
    type: file
    options:
      path: /etc/grafana/provisioning/dashboards
RouteWhen it fits
Provisioning filesOne Grafana, config in the image
Terraform providerMany environments, one source
HTTP API in CIAn existing pipeline, no new tool
Hand editNever, if you want it back

The dashboard nobody owns A panel with no owner is a panel nobody deletes. Add the team and the service to the dashboard tags.

A dashboard that cannot be rebuilt from the repository is a screenshot with extra steps.

The collector is configuration (pipelines)

Traces and logs travel through a pipeline, and that pipeline is a file. Validate it before it ships, and version it with the services it serves.

Validate before deploy

otelcol validate --config=otelcol.yaml
otelcol components

The collector config names receivers, processors, exporters and the service pipelines that connect them. A typo in a pipeline name is a silent drop, so validation belongs in CI next to the unit tests.

  • Set service.name and deployment.environment on every resource.
  • Sample at the collector, not in five client libraries.
  • Keep one gateway config, not one per team.
  • Alert on the collector's own queue depth and dropped data.

Cardinality is a budget A label with user ids turns a metric into a database. Decide the label set in the pull request, where it is cheap to argue about.

Telemetry you cannot validate is telemetry you will debug during an incident.

Ship it with an owner (ownership)

A rule, a dashboard or a pipeline without an owner is deleted by the next reorganisation. Ownership is part of the code, not a spreadsheet.

  1. Put the service name and team in every artefact's labels.
  2. Link the runbook from the alert annotation.
  3. Review the telemetry diff in the same pull request as the code.
  4. Apply through the pipeline, never from a laptop.
  5. Delete the signal when the service is retired.
FieldWhy it earns its place
serviceGroups signals by the thing that broke
teamRoutes the page to the people who fix it
runbookCuts the first five minutes of an incident
severityDecides page, ticket or dashboard

Slos as a file

sloth generate -i slo.yaml
kubectl apply -f slo-rules.yaml

The pull request is the control If the alert change and the code change can land separately, they will. One review, one rollback.

An alert with a team name and a runbook is a control. The rest is telemetry.

The honest caveat: code does not make a bad signal good. A noisy rule deployed by pipeline is still noisy, only now it pages every fifteen minutes.

The lesson: if you cannot rebuild the signal from the repository, you do not have it.

Your turn: Which signal would you struggle to rebuild today?

More notes: Automation & tooling

Open in the notes app: search, filters, copy This note on GitHub