AIOps Observer
← All labs

Prometheus alerting / Intermediate / 25–40 min

The alert that never stops firing

A real Prometheus alert treats a cumulative error counter as a current incident. Repair the PromQL and test it against healthy traffic, an error burst and a counter reset.

LAB IDaiops-03-prometheus-counter-alertTRACK / aiops.observer
Analyst monitoring system signals beside AI server hardware

The scenario

The service has accumulated errors over its lifetime, but the alert still fires when no errors are occurring. Keep detection for a recent burst, including after a counter reset.

Mission objectives

  • Run the real Prometheus rule tests and inspect the failing alert.
  • Change the alert expression to measure recent counter growth.
  • Verify healthy, burst and counter-reset cases with promtool.

Lab README

The alert that never stops firing

A Prometheus alert fires on a cumulative error counter even after errors stop. Repair the rule so it detects recent bursts instead of the lifetime total.

Before you begin

Use Docker, Bash and Python 3 on a disposable machine. The lab runs the official Prometheus promtool in disposable containers with no network or host ports, using fixed synthetic series. Docker may download the image and uses local disk and compute. No live Prometheus server or real incident data is used. The tests illustrate a small alert contract, not production thresholds.

./setup.sh
./lab.sh

Inspect rules.yml and the test cases. Modify the alert expression in rules.yml, keeping the alert name and severity. It must remain quiet when the counter is stable, alert on a recent burst, and handle a counter reset. Do not change cases.yml or the test runner.

./verify.sh
./teardown.sh

Verification checks the original test fixtures and runs the actual Prometheus rule evaluator. Teardown does not remove the shared Docker image or edited files; re-extract the bundle to reset the incident.

View Markdown source ↗

Get the lab

Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.

curl -fsSLO https://devops.download/labs/aiops-03-prometheus-counter-alert.sh
less aiops-03-prometheus-counter-alert.sh
bash aiops-03-prometheus-counter-alert.sh
cd labs/aiops-03-prometheus-counter-alert
./setup.sh

When you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.

Download the archive instead ↗

Need a nudge?

Hint #1

A counter is cumulative and may reset when a process restarts.

Hint #2

PromQL has a counter-aware function for the increase over a time window; keep the alert labels unchanged.

Hint #3 · Learning paths on opsbreakfix.com

Explore learning paths ↗

Solved it?

Continue learning with the paths on opsbreakfix.com.

Continue to opsbreakfix.com ↗

One ecosystem.
Many perspectives.

Follow the connection from a hands-on lab to the knowledge and tools behind it.