Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alerting): detect flapping alerts #148

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/prometheus_alert_rules/flapping.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
groups:
- name: AlertRules
rules:
- alert: AlertRulesFlapping
expr: changes(ALERTS_FOR_STATE{severity = "warning"}[1h]) > 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!
Apparently there also ALERTS, but the value there is "1", whereas for ALERTS_FOR_STATE it's timestamp.
How did you find out this exists?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Through @err404r :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALERTS is not working with changes for some reason, when I found this out I google and find out about ALERTS_FOR_STATE it is internal metrics which is used to track alert state in between prometheus restarts. According to official docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need to replicate the alert per severity?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, should we move this alert to prometheus? Seems like a generic alert rule.
We probably don't want topology injected here.
(And also we don't want prometheus topology injected there.)

for: 5m
simskij marked this conversation as resolved.
Show resolved Hide resolved
labels:
severity: warning
annotations:
summary: Host '{{labels.instance}}' suffers from flapping alerts.
simskij marked this conversation as resolved.
Show resolved Hide resolved
description: >-
Host '{{labels.instance}}' suffers from flapping warning-level alerts.
VALUE = {{ $value }}
LABELS = {{ $labels }}
14 changes: 14 additions & 0 deletions src/prometheus_alert_rules/host_health.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
groups:
- name: HostHealth
rules:
- alert: HostAvailable
expr: up < 1 or absent(up)
for: 5m
labels:
severity: warning
annotations:
summary: Host '{{labe;s.instance}}' is down.
description: >-
Host '{{ $labels.instance }}' is down.
VALUE = {{ $value }}
LABELS = {{ $labels }}