Error ratios & Prometheus-style rules

Alert on a symptom users can feel

Lesson 11 of 20 · 12 min · Module 4: A plan and actionable alerts

An alert should point to a meaningful condition that warrants action.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • Choose a symptom rather than a vague activity count
  • Use the recorded metric deliberately

The idea

An alert combines a defined metric, a condition, and a timing requirement. Its state should follow the supplied evidence, rather than the presence of a rule name.

groups:
  - name: capacity
    rules:
      - alert: LowDisk
        expr: disk_free_ratio < 0.1
        for: 10m

01Choose a symptom rather than a vague activity count

An error ratio can reflect a user-facing problem more directly than a raw count of log messages. The metric must have a documented meaning and unit.

02Use the recorded metric deliberately

This lab supplies a precomputed ratio and compares it with a threshold. It does not run a full Prometheus query engine or compute a rate from raw counters.

03Give the operator a useful signal

A named alert, severity, and clear annotation help someone decide what to investigate. An alert without an action can become ignored noise.

Your turn

Write a Prometheus rules YAML group notes with alert HighErrorRatio, expr http_error_ratio > 0.05, for 5m, and severity warning. The recorded ratio is 0.08 for 420 seconds, so it should fire.

What the checks look for

  • Names the intended symptom
  • Holds for five minutes before firing
  • Labels severity
Try it in the editor →

Take this with you

Connect alerts to meaningful symptoms and a documented response.

Go a little further

Write a useful annotation describing the first diagnostic action.

Learn Infrastructure & Operations for free

20 short lessons with real code and instant checks.

See the whole course →