prometheus / prometheus/docs

alertmanager: Add guidance on rate window vs "for"

Open
#1,262 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

diataxis/howto
Dominant language
TypeScript
Stars
717
Forks
1.2k
Avg merge
3d 15h
Merged PRs (30d)
19

Description

I think the documentation could do a better job explaining what for is for. The current documentation says this about the for field of an alert:

The optional for clause causes Prometheus to wait for a certain duration between first encountering a new expression output vector element and counting an alert as firing for this element. In this case, Prometheus will check that the alert continues to be active during each evaluation for 10 minutes before firing the alert. Elements that are active, but not firing yet, are in the pending state.

I had situation where an alert was firing too often and I wanted to make it more sensitive. Simplified example:

  - alert: HighErrorRate
    expr: rate(errors[5m])
    for: 10m

I wanted to figure out whether I should increase the rate range ([5m]) or increase the for: 10m. After some talking to people and reading the SRE Workbook, my conclusion was that, if you are measuring a rate or calculating an average, it is better to use only the range ([5m]), and omit the for. The reasoning seems to be that this improves time-to-detection and recall.

On the other hand, it seems like the best-case use for for is on gauges and boolean-valued time series.

Is that an accurate summary? If I wrote up a PR tweaking the docs to clarify that, would that be something you'd accept?

Thanks,
Jacob

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the documentation passage quoted in the issue and review Prometheus alerting guidance for the interaction between a rate range and the for duration. Verify the proposed distinction against the relevant alerting semantics, then update the documentation so readers can choose between these options and understand when each is appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
prometheus
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.