Learning center

An alert fired during the deploy. How often does it fire without one?

An alert that fires during a deploy implicates the deploy only if it fires less often when nothing is deploying. Count the alert's firings outside deploys to get its base rate, and work out the chance of at least one firing in a window as long as the deploy by coincidence: 1 - e^(-rate × window). Then compare the share of past deploys that saw a firing with the share of equal quiet windows that did; only the first explanation predicts a difference.

The symptom and two explanations#

The example is illustrative. A fictional checkout service started a rolling deploy of checkout:57 at 14:02 UTC, and the rollout finished at 14:47. At 14:19 the CheckoutLatencyHigh alert fired, and someone in the incident channel proposed rolling back. Someone else pointed out that the alert had fired eleven times the day before, with no deploy anywhere near most of them.

  • The deploy caused it. Something in checkout:57, or in the act of replacing tasks, pushed latency over the threshold.
  • It fires this often anyway. The alert crosses its threshold about once every two hours for reasons unrelated to deploys, and one of those crossings landed inside a 45-minute window.

Both explanations predict the observation everyone has: one firing during this deploy. A noisy alert fires during deploys at the same rate it fires during lunch, so the firing alone cannot choose between them. Choose the observation where explanations disagree

What each explanation predicts#

ObservationThe deploy caused itIt fires this often anyway
A firing during this deployyesyes
Firings per hour outside deploysany valuehigh enough that 1 - e^(-rate × window) is a large share
Share of past deploy windows with a firingwell above the share of quiet windowsabout the share of quiet windows
Where in the window the firings landat the same step of each rollout, such as new tasks taking trafficanywhere
The alerting signal split by revisionworse on the new revisionthe same on both

The first row is the one in the channel, and it separates nothing. The second row sets the expectation for coincidence: at 0.5 firings per hour, a 45-minute window holds at least one firing with probability 1 - e^(-0.375), about 31%. Roughly one deploy in three will "trigger" this alert by chance. The third row is the test. A deploy that causes the alert raises the deploy-window share above the quiet-window share; coincidence leaves the two equal.

The arithmetic assumes firings arrive independently at a steady rate, a Poisson process. Real alerts cluster, and the limits below say when that breaks the estimate.

The lab: a month of alert history#

The script simulates 30 days of an alert that fires 0.5 times an hour at random, and 60 deploys with 45-minute windows. In the coincidence world, the alert ignores deploys. In the caused world, half of the deploys also trip it. It then reads the history the way you would read a real one: the base rate from time outside deploys, the Poisson prediction from that rate, and the share of deploy windows and of quiet 45-minute windows that contain a firing. It needs Python 3.8 or later.

import math, random, sys

DAYS, RATE, WINDOW = 30, 0.5, 0.75      # 30 days; 0.5 firings/hour; 45-minute deploy window
if len(sys.argv) not in (2, 3) or sys.argv[1] not in ("coincidence", "caused"):
    sys.exit("Usage: python3 base_rate.py coincidence|caused [seed]")
world = sys.argv[1]
rng = random.Random(int(sys.argv[2]) if len(sys.argv) > 2 else 1)
hours = DAYS * 24

# 60 deploys at random times, at least 3 hours apart
deploys = []
while len(deploys) < 60:
    t = rng.uniform(0, hours - WINDOW)
    if all(abs(t - d) > 3 for d in deploys):
        deploys.append(t)
deploys.sort()

# Background firings: a Poisson process at RATE per hour, unrelated to deploys
firings, t = [], 0.0
while True:
    t += rng.expovariate(RATE)
    if t >= hours:
        break
    firings.append(t)
if world == "caused":                    # half of the deploys also trip the alert
    firings += [d + rng.uniform(0.05, 0.5) for d in deploys if rng.random() < 0.5]
firings.sort()

def in_deploy(t):
    return any(d <= t < d + WINDOW for d in deploys)

quiet_hours = hours - len(deploys) * WINDOW
base = sum(not in_deploy(f) for f in firings) / quiet_hours
predicted = 1 - math.exp(-base * WINDOW)

# Every 45-minute slot of the month that does not overlap a deploy window
slots = [s * WINDOW for s in range(int(hours / WINDOW))]
quiet = [s for s in slots if all(s + WINDOW <= d or s >= d + WINDOW for d in deploys)]

def hits(starts):
    return sum(any(s <= f < s + WINDOW for f in firings) for s in starts) / len(starts)

print(f"world={world}")
print(f"  base rate outside deploys      {base:.2f} firings/hour")
print(f"  chance of >=1 in 45 min        {predicted:.0%}  (Poisson, from the base rate)")
print(f"  quiet 45-min windows with one  {hits(quiet):.0%}  ({len(quiet)} windows)")
print(f"  deploy windows with one        {hits(deploys):.0%}  ({len(deploys)} deploys)")

Save it as base_rate.py. Before you run it, write down two numbers for each world: the share of deploy windows with a firing, and the share of quiet windows. The prediction is that they agree within a few points in the coincidence world and differ by tens of points in the caused world.

python3 base_rate.py coincidence
python3 base_rate.py caused

Python 3.11 printed:

world=coincidence
  base rate outside deploys      0.50 firings/hour
  chance of >=1 in 45 min        31%  (Poisson, from the base rate)
  quiet 45-min windows with one  29%  (840 windows)
  deploy windows with one        28%  (60 deploys)
world=caused
  base rate outside deploys      0.50 firings/hour
  chance of >=1 in 45 min        31%  (Poisson, from the base rate)
  quiet 45-min windows with one  29%  (840 windows)
  deploy windows with one        63%  (60 deploys)

In the coincidence world, 28% of deploys saw the alert fire, which is what the Poisson formula and the quiet windows both predicted. Each of those 17 deploys would have looked guilty to someone reading only its own window. In the caused world, the deploy share more than doubled while the base rate and the quiet-window share stayed where they were, because the base rate is measured outside deploys.

The prediction would have failed if the coincidence world had shown a deploy share far above the quiet share, or the caused world had not. Pass a seed as the second argument to repeat it: seeds 2, 3 and 4 gave deploy shares of 33%, 32% and 37% for coincidence against quiet shares of 31%, 33% and 27%, and 73%, 67% and 60% for caused. With only 60 deploys, a gap of a few points is noise; the standard error of a share near 30% from 60 deploys is about 6 points.

Read the base rate on a real system#

The observation needs two lists of timestamps covering the same period: when the alert started firing, and when each deploy started and finished serving.

For a CloudWatch alarm, describe-alarm-history returns state transitions with a timestamp and a summary such as Alarm updated from OK to ALARM. CloudWatch keeps alarm history for 30 days, so a month is the longest base rate it can give. describe-alarm-history · Alarm history retention

aws cloudwatch describe-alarm-history \
  --profile PROFILE --region REGION \
  --alarm-name CheckoutLatencyHigh --history-item-type StateUpdate \
  --start-date 2026-10-25T00:00:00Z --end-date 2026-11-24T00:00:00Z \
  --query 'AlarmHistoryItems[?contains(HistorySummary, `to ALARM`)].Timestamp' \
  --output text --no-cli-pager

Prometheus keeps a synthetic ALERTS series for every pending or firing alert, with an alertstate label. A firing starts in a minute where the series exists and did not exist a minute earlier; unless keeps the elements of the left side that have no match on the right, and a range query evaluates that expression at each step. ALERTS series · unless

ALERTS{alertname="CheckoutLatencyHigh", alertstate="firing"}
unless
ALERTS{alertname="CheckoutLatencyHigh", alertstate="firing"} offset 1m

Run this as a range query over 14 days with a one-minute step. Collect the returned sample timestamps for each alert series. Exclude starts inside any deploy window, then divide the remaining count by the hours outside the union of those windows. Use the same time bounds for both lists. A firing shorter than the query step can be missed. Prometheus retains 15 days of samples by default, so a longer range returns less than it asks for unless retention was raised. Retention

Deploy windows come from the deployment records of the platform, not the pipeline's start time. When did the rollout start serving? The lab accepts start times for non-overlapping 45-minute windows. For real rollouts, keep each start and finish. Count a firing when it falls at or after the start and before the finish. Merge overlapping intervals before subtracting deployed time from total hours. For each rollout, compare a quiet window of the same length and compute its coincidence probability using that duration.

Where the base rate misleads#

Deploys are not spread at random over the day. Most teams deploy in working hours, when traffic and latency alerts peak. Compare each deploy window with the same clock time on other days without a deploy, rather than with all quiet windows, or the busy hours will make the deploy share look high. A regression, or the same weekly pattern?

Alerts cluster. A flapping alert that fires five times in ten minutes counts as five firings in the rate but one event in a window, and a Poisson estimate built from the raw count overstates the chance of coincidence. Count windows with at least one firing, as the lab does, rather than firings per window.

A small history decides little. With ten deploys and a 30% chance per window, anything from one to five deploy windows with a firing is ordinary chance. The comparison gains power across many deploys of the same service, or from the fifth row of the table: the alerting signal split by revision over the same minutes. Split errors by revision

A deploy share equal to the quiet share says the alert does not track deploys in general. This one deploy can still have caused this one firing, and a new revision that is worse than the old one in the same minutes is evidence of that whatever the history says.

Questions#

How do I calculate the chance an alert fires during a deploy by coincidence?

Measure the alert's firings per hour over a period without deploys, multiply by the deploy window in hours, and take 1 - e^(-rate × window). At two firings a day and a 30-minute window, the chance is about 4%; at twelve a day and 45 minutes, about 31%.

How many past deploys do I need for the comparison?

Enough that the gap you care about exceeds the noise. The standard error of a share p from n deploys is about √(p(1 - p)/n), so 60 deploys distinguish 30% from 60% easily and 30% from 36% not at all. With fewer deploys, rely on the split by revision instead.

The alert fires a dozen times a day. Should it page at all?

That is a separate decision from this incident, but the base rate you just measured is the evidence for it. An alert that fires during a third of deploys by chance trains people to roll back for no reason, and to ignore it when the deploy is the cause.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading