11/26
Sign inSign up free

1432. Recording Rules for the Shop

medium 20 XP ~15 minHands-on lab

A small online shop's dashboards run the same request-rate and error-ratio queries on every refresh, and so does its error alert. The team wants Prometheus to compute them once, as recording rules.

The shop's five services count their requests in http_server_requests_total, labelled with service, route and status (the HTTP status code).

ToolHoldsAddress on this machine
Grafanadashboards and Explore for the three belowhttp://127.0.0.1:3000
Prometheusmetrics and alert ruleshttp://127.0.0.1:9090
Lokilogshttp://127.0.0.1:3100
Tempotraceshttp://127.0.0.1:3200

Open Grafana and Prometheus with the buttons above the terminal. Prometheus reads /etc/obs/prometheus.yml and the rules in /etc/obs/rules.yml.

Task

  1. Add a rule group named shop-recordings to /etc/obs/rules.yml with two recording rules:
    • service:http_server_requests:rate5m: requests per second of each service over 5 minutes, one series per service, labelled only with service.
    • service:http_server_errors:ratio_rate5m: the share of each service's requests over 5 minutes that answered with a 5xx status (0 to 1), one series per service, labelled only with service.
  2. Change the alert FrontendErrorRateHigh so it uses service:http_server_errors:ratio_rate5m for frontend, with the same threshold (5%) and for as now.
  3. Prometheus must have loaded the rules, and both recorded series must exist.

About this machine

Ubuntu 24.04 with no internet access, running the real Prometheus, Loki, Tempo and Grafana (unmodified) and a simulated shop that reports to them. Once the machine is running, Grafana and Prometheus open in a new tab from the buttons above the terminal. The history goes back about an hour. curl, jq and promtool are installed. The grader checks your answer, not the commands you typed. BrokenCluster is not affiliated with, endorsed or sponsored by Grafana Labs or the Prometheus project.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.