main where any test failure is unexpected and worth investigating immediately.
When to Use This Monitor
Use the failure count monitor when you want immediate visibility into test failures on branches that should be green. Common scenarios:- Stable branch alerting: Flag any test that fails on
main, even once. On a branch where all tests should pass, a single failure is a meaningful signal. - Post-merge regression detection: Catch tests that start failing after a merge, before the failure rate accumulates enough data for a failure rate monitor to trigger.
- High-confidence branches: Monitor merge queue or release branches where failures are suspicious by definition.
How It Works
The monitor counts the number of test failures on configured branches within a rolling time window. When a test reaches the configured failure count, the monitor activates and runs its configured action — by default, flagging the test as flaky or broken.Example
You configure a failure count monitor with:
A developer merges a change that breaks
test_checkout. Here is what happens:
test_checkoutfails on the next CI run onmain.- The monitor sees 1 failure within the 30-minute window, which meets the configured failure count of 1.
test_checkoutis immediately flagged as broken.- The developer identifies the issue and merges a correction.
- Two hours pass with no new failures for
test_checkout. - The monitor automatically resolves the test back to healthy.
test_signup, also failed during that window, it would be flagged independently. Each test is evaluated on its own.
Configuration
Failure Count
The number of failures required to trigger detection. The default is 1, meaning any single failure on a monitored branch flags the test. Setting this higher (e.g., 3) requires multiple failures before the monitor reacts. This is useful if you want to filter out one-off infrastructure blips while still catching tests that fail repeatedly in a short window.Window Duration
The rolling time window over which failures are counted. Only test failures within this window contribute to the failure count. A shorter window (e.g., 30 minutes) limits detection to very recent failures. A longer window (e.g., 6 hours) catches failures that are spread out over time but still accumulating. The window should be long enough to capture the failures you care about but short enough that old failures roll off naturally. For a monitor with a failure count of 1, the window mainly controls how quickly a detection event is created after a failure. In practice, the pipeline evaluates frequently, so detection is near-immediate regardless of window size.Resolution Timeout
How long a flagged test must go without any new failures before it is automatically resolved. This is the only way a failure count monitor resolves — there is no “recovery rate” or sample-based resolution like the failure rate monitor, and no stale timeout. If a test stops running entirely (e.g., it was deleted or renamed), it stays flagged until the resolution timeout elapses from its last observed failure. For example, with a resolution timeout of 2 hours, a test that was flagged at 3:00 PM will resolve at 5:00 PM if no new failures occur. If a new failure arrives at 4:30 PM, the clock resets, and the test will not resolve until 6:30 PM. The resolution timeout must be at least as long as the detection window. If the window is 30 minutes, the resolution timeout should be 30 minutes or longer. Choose a resolution timeout that gives your team enough time to verify a fix has landed. A short timeout (e.g., 30 minutes) resolves quickly but may prematurely clear tests that fail intermittently. A longer timeout (e.g., 24 hours) is more conservative and ensures the test stays flagged until it has been clean for a full day.Branch Scope
Which branches the monitor evaluates. You can specify branch names or glob patterns. Only test failures on matching branches count toward the failure count. Branch patterns work the same way as failure rate monitor branch patterns, including glob syntax and merge queue patterns. Refer to that section for pattern syntax, examples, and tips.Action
What happens when the monitor activates on a test. You pick the action at creation and can switch it at any time. Classify test status (default). The test’s status is set according to the monitor’s detection type, and restored to healthy when the monitor resolves. The detection type is either:- Flaky — appropriate when failures on the monitored branch are likely non-deterministic. A test that fails once on
mainbut passes on retry is probably flaky. - Broken — appropriate when failures indicate a real regression. If a test fails on
mainand you expect it to keep failing until someone fixes it, broken is the right classification.