Definition · Scrape intervalThe scrape interval I is the period at which a monitoring system reads a target’s current metric values. For a gauge, the value recorded is the one in effect at the instant of the read. For a counter, what is stored is the running total, and a rate is computed as the difference between two reads divided by the time between them.
Theorem · The probability of catching a spikeLet a spike of duration d begin at a time uniformly distributed relative to the scrape clock, and let reads occur every I. If d ≥ I at least one read falls inside the spike and it is caught with certainty. If d < I the spike covers a fraction d/I of the scrape cycle, so
P(caught) = min(1, d/I).
The assumption is the uniformity. It fails exactly when the spike is produced by something on a clock of its own — a cron job, a flush every sixty seconds, or the scrape itself — in which case the phase is fixed and the probability is not d/I but zero or one, permanently.
That failure mode is worth more than the formula. A spike that is always missed is indistinguishable from no spike, and a periodic job whose period shares a factor with the scrape interval produces exactly that. If a graph is suspiciously flat, changing the interval to a value coprime with your suspicions is a cheap experiment.
I = 15 s, d = 3 s
P(caught) = 3/15 = 1/5 = 20%
so four spikes in five leave no trace at all
longest spike that can fall entirely between two reads:
a spike of d seconds contains a read unless it fits strictly
inside one gap, which needs d ≤ I − 1 at one-second resolution
I = 15 s → 14 s
I = 60 s → 59 s
I = 1 s → 0 s nothing can hide
Fourteen seconds is the figure to carry away. At the default fifteen-second interval that most monitoring is configured with, an outage lasting a quarter of a minute can leave a completely flat graph, and the graph is not lying: it is reporting every value it was given.
One run is not the probability
The lab draws a run of spikes at seeded times across five minutes and lays the scrape instants over them. At d = 3 and I = 15 the expected fraction caught is a fifth, and the fraction actually caught on a given run is some other number near it — which is what a single afternoon of monitoring is. Reseed and it changes; the probability does not.
This is the same distinction the first page of the course made about a measured ratio, arriving in a different costume. 1/5 is a property of the configuration; “we caught three of twelve yesterday” is a measurement with its own error bar, and twelve spikes is a very small sample.
Example · A quarter-minute outage that nothing recordedA service fails hard for twelve seconds and recovers. The scrape interval is fifteen seconds; the outage happens to start two seconds after a read and end one second before the next. Error-rate gauges read zero on both sides. The request counter, being cumulative, does carry the missing successes — a dip in the computed rate that is real and easy to dismiss — but every gauge-based panel and every alert built on one saw a healthy system throughout. Users saw twelve seconds of errors.
The second thing the interval hides: a counter that reset
Counters only go up, so monitoring systems compute rates by differencing consecutive reads. A process restart sets the counter back to zero, and the restart itself happens between two reads where nothing can observe it. The only evidence is that the second read is smaller than the first, and a naive difference turns that into a spectacular negative rate.
a counter climbing at 40/s, read every 15 s, process restarts at 152 s
read at 150 s 40 × 150 = 6 000
read at 165 s 40 × (165 − 152) = 520
naive rate (520 − 6 000)/15 = −365.33/s
corrected a decrease means a restart, so take the new read:
520/15 = +34.67/s
true rate 40.00/s
unrecoverable 40 × (152 − 150) = 80 increments
The corrected rate is 34.67 rather than 40 and the gap is exactly the eighty increments that accumulated between the last read and the restart. They are gone: the process that held them no longer exists, and no correction applied downstream can recover a number nobody read. What the correction buys is a rate that is positive, approximately right, and does not poison every aggregate it feeds.
Notice how the error behaves if the restart happens earlier in the window. Once the counter has climbed past its previous reading before the next scrape, the difference is positive again and nothing looks wrong at all — the restart is then completely invisible, and the rate it reports is understated by however much was lost. The large negative number is the friendly case.