tune Targets Missing rules (#497)

* tune Targets Missing rules

* reworked query logic

* Update rules.yml

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
This commit is contained in:
dxrayz 2026-02-21 20:40:10 +02:00 committed by GitHub
parent 9998e22145
commit e60601fdcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -19,8 +19,11 @@ groups:
severity: warning
- name: Prometheus target missing
description: A Prometheus target has disappeared. An exporter might be crashed.
query: "up == 0"
query: "up == 0 unless on(job) (sum by (job) (up) == 0)"
severity: critical
comments: |
Only fire if at least one target in the job is still up.
If all targets are down, PrometheusJobMissing or PrometheusAllTargetsMissing will fire instead.
- name: Prometheus all targets missing
description: A Prometheus job does not have living target anymore.
query: "sum by (job) (up) == 0"

View file

@ -15,7 +15,7 @@ groups:
description: "A Prometheus job has disappeared\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
- alert: PrometheusTargetMissing
expr: 'up == 0'
expr: 'up == 0 unless on(job) (sum by (job) (up) == 0)'
for: 0m
labels:
severity: critical