Skip to content

prometheus: move the Grafana-managed alerts into alert_ooni.yml - #537

Open
aagbsn wants to merge 1 commit into
mainfrom
grafana_alerts_in_git
Open

aagbsn wants to merge 1 commit into
mainfrom
grafana_alerts_in_git

Conversation

@aagbsn

@aagbsn aagbsn commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

They lived in Grafana's database, out of git, and went out through Grafana's own notifications. Now they're Prometheus rules next to the others, sent by Alertmanager, with promtool tests in roles/prometheus/tests/alert_ooni_test.yml.

Moved: Service down, api.ooni.io HTTPS probe status, Incoming msmts per second (AWS), Blackbox HTTPS body length, API uploader total runtime, Generate test list timing, MMDB database node count and the NTP offset ("Panel Title alert"), with the same queries and thresholds.

Not moved: the collector and test helper probe checks, which BlackboxDown already covers; the SSH check, on up{job="ssh"}, which no job scrapes; and the paused ones, on ams-pg's netdata and backend-fsn's measurement rate.

They lived in Grafana's database, out of git, and went out through
Grafana's own notifications. Now they're Prometheus rules next to the
others, sent by Alertmanager, with promtool tests in
roles/prometheus/tests/alert_ooni_test.yml.

Moved: Service down, api.ooni.io HTTPS probe status, Incoming msmts per
second (AWS), Blackbox HTTPS body length, API uploader total runtime,
Generate test list timing, MMDB database node count and the NTP offset
("Panel Title alert"), with the same queries and thresholds.

Not moved: the collector and test helper probe checks, which
BlackboxDown already covers; the SSH check, on up{job="ssh"}, which no
job scrapes; and the paused ones, on ams-pg's netdata and backend-fsn's
measurement rate.
@aagbsn

aagbsn commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

● Here are the steps, in order. The Grafana rules are deleted last, only once the new rules are live and you've seen
an alert reach Slack, so there's never a period with no alerting.

  1. Run the tests and push

cd ~/devops-grafana-alerts/ansible/roles/prometheus
podman run --rm -v "$PWD:/w:ro" -w /w/tests --entrypoint /bin/promtool docker.io/prom/prometheus:v2.42.0 test rules
alert_ooni_test.yml
cd ~/devops-grafana-alerts && git push -u origin grafana_alerts_in_git
Then open a PR into main.

we are here

  1. Check that the netdata metrics still exist

Three of the rules read netdata metrics from backend-fsn. If a metric is gone, its rule can never fire, and
Grafana's "No data" warning no longer exists to tell you. In Prometheus, each of these should return a series:
netdata_statsd_timer_ooni_api_uploader_total_run_time_milliseconds_average{dimension="95.0%"}
netdata_statsd_timer_ooni_api_generate_test_list_milliseconds_average{dimension="median"}
netdata_statsd_gauge_ooni_download_geoip_geoip_cc_node_cnt_value_average
If one returns nothing, remove its rule in the PR instead of carrying a dead alert.

  1. Don't let the deploy remove Clickhouse backup #520's backup alerts

The role copies every alert_*.yml file from the branch you deploy. On monitoring.ooni.org, check whether the backup
alerts are live:
curl -s localhost:9090/api/v1/rules | jq -r '.data.groups[].name'

  • "ClickHouse backups" isn't in the list: deploy after this PR merges, from main.
  • It is in the list: merge Clickhouse backup #520 first, or deploy from a local branch that has both:
    git -C ~/devops switch -c deploy-monitoring origin/main
    git -C ~/devops merge origin/clickhouse-backup grafana_alerts_in_git
    Run that in a clean worktree, since ~/devops has your uncommitted change.
  1. Deploy

./play deploy-monitoring.yml -l monitoring.ooni.org --diff -C
The diff should show only alert_ooni.yml gaining the "OONI services" group. If alert_rules.yml loses its "ClickHouse
backups" group, stop and go back to step 3. Otherwise apply it:
./play deploy-monitoring.yml -l monitoring.ooni.org --diff

  1. Check the rules are loaded and that delivery works

On monitoring.ooni.org:
curl -s localhost:9090/api/v1/rules | jq -r '.data.groups[] | select(.name == "OONI services") | .rules[].name'
That should print all 9 rule entries (GeoIPDatabaseSmall appears twice). Any alert that's firing right now shows on
Prometheus' Alerts page.

To confirm messages actually reach Slack, send a test alert that expires after 5 minutes. It will post in #ooni-bots
and email arturo and mehul:
curl -s -XPOST localhost:9093/api/v2/alerts -H 'Content-Type: application/json' -d
"[{"labels":{"alertname":"AlertingTest","instance":"monitoring"},"annotations":{"summary":"Test alert
after moving the Grafana alerts, ignore"},"endsAt":"$(date -u -d '+5 min' +%FT%TZ)"}]"
If nothing shows up within a minute, fix delivery first, as in the earlier troubleshooting. Don't delete the Grafana
rules while Alertmanager can't reach Slack.

  1. Remove the Grafana alerts

First keep a copy of the export (the YAML you pasted). Then either:

  • In the UI: Alerting → Alert rules, folders "Alerting" and "Services". For each rule, ⋮ → Delete. There are 15
    rules in total, including the paused ones.
  • With the API: create a service account with the Admin role (Administration → Users and access → Service accounts),
    add a token, then run:
    TOKEN=... # the service account token
    for uid in 6oTZ1R7Vk N0TZ1Rn4z zJoW1gn4z 90TW1g74k LTTWJg7Vz _ATWJgnVk
    dd04d4fd-962e-48fd-a953-b118922e60eb g1TWJg74z vATZ1g74z MATZJR7Vk
    e0TW1gn4z 3gZ8lwVVz 9De9dx4Vz PWddsfV4z fbb91efd-460b-4d1c-bc6f-4be68ff8daa1; do
    printf '%s ' "$uid"
    curl -s -o /dev/null -w '%{http_code}\n' -X DELETE -H "Authorization: Bearer $TOKEN"
    "https://grafana.ooni.org/api/v1/provisioning/alert-rules/$uid"
    done
    Each line should print 204. Delete the service account afterwards.

To check that nothing is left:
curl -s -H "Authorization: Bearer $TOKEN" https://grafana.ooni.org/api/v1/provisioning/alert-rules | jq length
This should print 0. If the folders "Alerting" and "Services" are now empty, delete them as well.

  1. Optional: tidy Grafana's notification settings

Under Alerting → Contact points, and Notification policies, anything that only served these alerts can go, such as a
Slack webhook contact point. Nothing else uses them once the rules are deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant