Prometheus missing series: distinguish zero, failed scrapes and vanished targets
Explain why up equals zero does not catch every missing target. Separate scrape failures from absent series and compare expected targets against observed telemetry.
TL;DR:
up == 0detects failed scrapes for targets Prometheus still knows about. A target removed from discovery can disappear from the query entirely. Use explicit absence checks or an expected-target inventory when missing telemetry itself must trigger a named alert.
An empty vector is not a numeric zero
A query can return a sample with value zero, or no sample at all. Those are different results. Arithmetic and comparisons operate on existing series; they do not invent a missing service's label set. A dashboard that fills gaps with zero can hide the distinction even though alert evaluation still sees it.
Prometheus's function reference defines absent and absent_over_time. For a selector, absent_over_time(metric[5m]) can report that the range contains no matching samples. It does not automatically enumerate every individual target that ought to exist.
Work three different failures
Assume a teaching inventory expects API targets a and b. At first both are discovered and scraped. Then b times out: its scrape-generated up is zero, so a suitable up == 0 alert can match it. Finally, the discovery source drops b; after its series becomes stale, an instant query can have no up sample for b at all.
| State | Observed query result | What it establishes |
|---|---|---|
| Scrape succeeds | up is one | Metrics endpoint was successfully scraped |
| Discovered scrape fails | up is zero | Collection failed for a known target |
| Target no longer represented | No current series | Observation is absent; compare with expectation |
| Application returns errors | up may still be one | Scrape success does not establish user success |
A job-wide absent(up{job="api"}) stays empty while target a remains, so it cannot identify missing b. For per-target completeness, compare a maintained expected-target metric with observed presence using a stable matching key. Define how that expectation is updated during intentional scale-down so ordinary lifecycle changes do not page as incidents.
Choose a detection window deliberately
An absence window tolerates short collection gaps but delays detection. Its duration should account for scrape interval, discovery timing and the operational consequence of missing evidence. Alert for duration adds another persistence requirement; it is not automatically the same window as absent_over_time.
Keep a separate check on the expectation source itself. If expected-target inventory disappears along with observed telemetry, a set comparison can falsely look empty. Similarly, a fully unavailable Prometheus server cannot reliably notify about its own missing evaluations through the same failed path; use independent monitoring appropriate to the service.
Review scraping and staleness for why series leave instant queries. Do not “repair” this by adding arbitrary zeros to every metric: the result may assert health without evidence.
Self-check: five expected targets exist, four scrape successfully and one disappears from discovery. Does absent(up{job="api"}) identify the missing target? No. The selector still returns four series. Preserve an expected set with the target identity required by the alert.