The symptom and four explanations#
The example is fictional. At 03:12 UTC the orders-api panel "orders per second" fell from about 140 to 0 and stayed there. The panel's query ends in or vector(0), a common way to keep a panel from showing "no data", so an empty result draws as a flat line at zero. Four explanations fit the line:
- No traffic arrives. Something upstream, such as a routing rule or a DNS change, stopped sending requests to the service, which is idle and healthy.
- The service crashed. The processes are gone, and clients get errors from the load balancer.
- The scrape fails. The service is serving normally, but Prometheus cannot reach its metrics endpoint, for example after a network policy or port change.
- The series was renamed. A deploy at 03:11 changed the label
handlertoroute, so the panel's selector{handler="/orders"}matches nothing while the new series counts every request.
Two of the four are faults in the telemetry while the service works, and all four draw the same line, which is why the graph cannot settle them. Choose the observation where explanations disagree
What each explanation predicts#
| Observation | No traffic | Crashed | Scrape fails | Renamed |
|---|---|---|---|---|
| The panel | 0 | 0 | 0 | 0 |
up for the targets | 1 | 0 | 0 | 1 |
The panel's series without or vector(0) | present, value 0 | absent | absent | absent |
| Load balancer request count to the targets | 0 | errors from the load balancer | normal, 2xx | normal, 2xx |
| Series of the same metric with a new label set | none | none | none | present since 03:11 |
The panel separates nothing. The second and third rows split a real zero from a missing series: Prometheus's up is 1 when a scrape succeeded and 0 when it failed, and a series that a successful scrape stops returning, or whose target stops answering, is marked stale and then returns no value at all. Jobs and instances · Staleness The load balancer row then splits a crash from a failed scrape, and the last row finds the rename.
The lab: four worlds behind one panel#
The script starts a small HTTP server with two ports, one for /orders and one for /metrics in the Prometheus text format, and runs six ticks. Each tick sends 40 to 60 requests through a client that plays the load balancer, then scrapes the metrics port and computes what the panel would show: the counter's increase for {handler="/orders"}, "no data" when that series is missing, and the same value with or vector(0). At tick 4 each world breaks in its own way. It needs Python 3.8 or later and nothing else.
import http.server, random, sys, threading, urllib.error, urllib.request
if len(sys.argv) < 2 or sys.argv[1] not in ("no-traffic", "crashed", "scrape-broken", "relabel"):
sys.exit("usage: python3 zero.py no-traffic|crashed|scrape-broken|relabel [seed]")
world = sys.argv[1] # no-traffic | crashed | scrape-broken | relabel
rng = random.Random(int(sys.argv[2]) if len(sys.argv) > 2 else 1)
state = {"count": 0, "label": "handler"}
class Handler(http.server.BaseHTTPRequestHandler):
def log_message(self, *args): pass
def do_GET(self):
if self.path == "/orders":
state["count"] += 1
body = b"ok\n"
else: # /metrics, Prometheus text format
body = f'http_requests_total{{{state["label"]}="/orders"}} {state["count"]}\n'.encode()
self.send_response(200); self.end_headers(); self.wfile.write(body)
def serve():
s = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler)
threading.Thread(target=s.serve_forever, daemon=True).start()
return s
app, metrics = serve(), serve() # traffic port and metrics port
def get(server, path):
port = server.server_address[1]
with urllib.request.urlopen(f"http://127.0.0.1:{port}{path}", timeout=1) as r:
return r.read().decode()
def scrape(): # returns up, {series: value}
try:
text = get(metrics, "/metrics")
except (urllib.error.URLError, ConnectionError):
return 0, {} # failed scrape: up 0, series go stale
return 1, {line.rsplit(" ", 1)[0]: int(line.rsplit(" ", 1)[1]) for line in text.splitlines()}
prev = scrape()[1] # a baseline scrape before tick 1
print(f"world={world}")
print("tick lb_2xx lb_5xx up dashboard{handler} or vector(0) series")
for tick in range(1, 7):
if tick == 4: # the event, at the same tick in every world
if world == "crashed":
app.shutdown(); app.server_close(); metrics.shutdown(); metrics.server_close()
elif world == "scrape-broken":
metrics.shutdown(); metrics.server_close()
elif world == "relabel": # a deploy restarts the process with a renamed label
state.update(count=0, label="route")
sent = 0 if (world == "no-traffic" and tick >= 4) else rng.randint(40, 60)
ok = bad = 0
for _ in range(sent): # the load balancer's view of the same traffic
try:
get(app, "/orders"); ok += 1
except (urllib.error.URLError, ConnectionError):
bad += 1 # an LB would answer 502 here
up, cur = scrape()
sel = 'http_requests_total{handler="/orders"}'
dash = str(cur[sel] - prev[sel]) if sel in cur and sel in prev else "no data"
zero = "0" if dash == "no data" else dash
print(f"{tick:>4} {ok:>6} {bad:>6} {up:>2} {dash:>18} {zero:>12} {', '.join(cur) or '-'}")
prev = cur
Save it as zero.py. Before you run it, write down, for ticks 4 to 6 of each world, the values you expect in the up, dashboard{handler} and lb_2xx columns. Then run:
for w in no-traffic crashed scrape-broken relabel; do python3 zero.py "$w"; done
Python 3.11 printed:
world=no-traffic
tick lb_2xx lb_5xx up dashboard{handler} or vector(0) series
1 44 0 1 44 44 http_requests_total{handler="/orders"}
2 58 0 1 58 58 http_requests_total{handler="/orders"}
3 42 0 1 42 42 http_requests_total{handler="/orders"}
4 0 0 1 0 0 http_requests_total{handler="/orders"}
5 0 0 1 0 0 http_requests_total{handler="/orders"}
6 0 0 1 0 0 http_requests_total{handler="/orders"}
world=crashed
tick lb_2xx lb_5xx up dashboard{handler} or vector(0) series
1 44 0 1 44 44 http_requests_total{handler="/orders"}
2 58 0 1 58 58 http_requests_total{handler="/orders"}
3 42 0 1 42 42 http_requests_total{handler="/orders"}
4 0 48 0 no data 0 -
5 0 43 0 no data 0 -
6 0 55 0 no data 0 -
world=scrape-broken
tick lb_2xx lb_5xx up dashboard{handler} or vector(0) series
1 44 0 1 44 44 http_requests_total{handler="/orders"}
2 58 0 1 58 58 http_requests_total{handler="/orders"}
3 42 0 1 42 42 http_requests_total{handler="/orders"}
4 48 0 0 no data 0 -
5 43 0 0 no data 0 -
6 55 0 0 no data 0 -
world=relabel
tick lb_2xx lb_5xx up dashboard{handler} or vector(0) series
1 44 0 1 44 44 http_requests_total{handler="/orders"}
2 58 0 1 58 58 http_requests_total{handler="/orders"}
3 42 0 1 42 42 http_requests_total{handler="/orders"}
4 48 0 1 no data 0 http_requests_total{route="/orders"}
5 43 0 1 no data 0 http_requests_total{route="/orders"}
6 55 0 1 no data 0 http_requests_total{route="/orders"}
The or vector(0) column is identical in all four worlds from tick 4. Only the no-traffic world produced a real zero, a present series whose value stopped rising. The crashed and scrape-broken worlds both lost the series and up, and only the load balancer columns told them apart. The relabel world kept up at 1 and served every request; its series column names the new label.
The prediction fails if any world other than no-traffic shows a numeric 0 in the dashboard{handler} column, or if the scrape-broken world shows up 1. Change the seed with python3 zero.py relabel 2: the request counts change, and the pattern of up, presence and load balancer counts does not.
Read it on a real system#
All of these only read. Start with the scrape itself, then the series without the panel's fallback:
up{job="orders-api"}
http_requests_total{job="orders-api", handler="/orders"}
absent(http_requests_total{job="orders-api", handler="/orders"})
absent() returns a one-element vector with the value 1 when its argument has no elements, and nothing when the series exists, so it is the direct test for "missing, not zero". absent_over_time() does the same over a range. absent · absent_over_time
To find a rename, select the metric with no label filter except the job and compare the label sets before and after the deploy. scrape_series_added counts the approximate number of new series in each scrape, so a deploy that renamed a label shows a step there. Jobs and instances
count by (handler, route) (http_requests_total{job="orders-api"})
scrape_series_added{job="orders-api"}
For the independent count on AWS, an Application Load Balancer's HTTPCode_Target_2XX_Count counts responses the targets generated, and HTTPCode_ELB_5XX_Count counts 5xx responses the load balancer generated itself, which is what clients see when the targets are gone. CloudWatch reports HTTPCode_ELB_5XX_Count only when the value is nonzero, so a missing data point there means zero errors. Application Load Balancer metrics
aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB \
--metric-name HTTPCode_Target_2XX_Count \
--dimensions Name=LoadBalancer,Value=app/orders-alb/0123456789abcdef \
Name=TargetGroup,Value=targetgroup/orders-api/0123456789abcdef \
--start-time 2026-11-20T02:50:00Z --end-time 2026-11-20T03:40:00Z \
--period 60 --statistics Sum --output table
aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB \
--metric-name HTTPCode_ELB_5XX_Count \
--dimensions Name=LoadBalancer,Value=app/orders-alb/0123456789abcdef \
--start-time 2026-11-20T02:50:00Z --end-time 2026-11-20T03:40:00Z \
--period 60 --statistics Sum --output table
A synthetic check, or the access logs of any proxy in front of the service, serves the same purpose. What matters is that it does not share the metrics pipeline with the panel.
Limits#
The independent signal shows what reached the load balancer, not why. A real zero at the load balancer still leaves the upstream cause open, and an error rate at the load balancer that rose at the same minute raises the question of whether errors rose or traffic fell.
A service can keep answering scrapes while it serves nothing, for example when request threads hang but the metrics endpoint runs on its own thread or port. Then up is 1 and the counter is flat, which looks like no traffic. The load balancer separates the two: idle targets get no requests, hung targets get requests that time out or fail.
Pushed metrics have no up. An agent or SDK that pushes to a collector, or to CloudWatch, simply stops sending when it dies, and absence is the only sign. A CloudWatch alarm configured with notBreaching treats missing data points as good, so a dead agent can leave the alarm green. Alarms and missing data
Staleness has exceptions. Series from exporters that put their own timestamps on samples keep their last value for the lookback period, 5 minutes by default, before they disappear, so a broken scrape can look like a flat line for a few minutes first. Staleness
Questions#
Why does the dashboard show zero when the series is missing?
Usually because the query appends a fallback such as or vector(0), which returns a zero sample whenever the left side is empty. Remove the fallback, or run the selector alone, and the difference between an empty result and a zero becomes visible. Prometheus's own guidance is to export a default value such as 0 for counters you know about, so that "nothing happened" is a sample and not an absence. Avoid missing metrics
Does up equal 1 mean the service is healthy?
It means the last scrape reached the target and succeeded. A process can answer its metrics endpoint while its request handlers fail or hang, so read up as "the telemetry for this target is arriving", and read health from the requests themselves.
How do I alert on a metric that disappears?
Alert on up == 0 for scraped targets, and on absent() or absent_over_time() for the specific series a dashboard or alert depends on. An alert on the rate alone, such as "orders per second below 1", cannot fire on a series that no longer exists unless the query supplies a fallback, and with a fallback it cannot tell the two cases apart.