A gateway that loses uplink does not produce one alert. It produces an alert per sensor for as long as it is down. With 18 sensors behind a gateway, a 40-minute outage is 720 alerts arriving at once, all describing the same event, all stamped with the sensor's local clock, and all competing with the actual incident that the operator is trying to handle.
Alert noise is not a cosmetic problem. It is the mechanism by which monitoring systems get muted, and muted monitoring is worse than no monitoring because it creates false confidence.
This post is the six-layer pipeline that reduced alert volume on a 2,000-sensor fleet from ~14,000 events per day to ~1,150 — a 92% reduction — while increasing the number of incidents the team acted on.
Measure before you fix
You cannot tune noise you have not counted. Two numbers first:
events_per_day
alerts_per_incident = events_per_day / incidents_per_day
In the fleet above, the starting point was 14,000 events/day against roughly 26 real incidents/day — about 540 alerts per incident. A healthy target is 3–10. Everything below is chosen to move that ratio, not to make dashboards look calm.
Layer 1: Fingerprint deduplication
The same rule firing repeatedly for the same device must collapse into one alert with an occurrence count, not N alerts.
The fingerprint must include exactly the identity of the condition — rule, device, and the specific entity the rule is about — and exclude anything that changes on every evaluation:
import hashlib, json
def fingerprint(ev: dict) -> str:
key = {
"rule": ev["rule_id"],
"device": ev["device_id"],
"entity": ev.get("entity", ""), # e.g. sensor channel, not the whole device
"severity": ev["severity"],
}
return hashlib.sha1(json.dumps(key, sort_keys=True).encode()).hexdigest()[:16]
Do not include: timestamp, metric value, model score, gateway, or correlation id. Including the value means every new reading is a new alert — which is exactly the bug you are trying to fix.
Then hold state per fingerprint:
from dataclasses import dataclass, field
import time
@dataclass
class AlertState:
fingerprint: str
first_seen: float
last_seen: float
count: int = 1
notified: bool = False
cooldown_until: float = 0.0
def observe(self, now: float, cooldown_s: float = 900) -> str:
self.last_seen = now
self.count += 1
if not self.notified:
self.notified = True
self.cooldown_until = now + cooldown_s
return "notify"
if now >= self.cooldown_until:
# re-notify a still-active condition at a bounded rate
self.cooldown_until = now + cooldown_s
return "renotify"
return "suppress"
Two subtle decisions here: re-notification is rate-limited rather than forbidden (a stuck condition must not go silent forever), and the state is keyed by fingerprint, not by device, so two independent problems on one device each get their own lifecycle.
Layer 2: Cascade grouping by topology
A gateway outage, a power loss, or a shared-modbus failure produces many fingerprints at once. Those should arrive as one grouped event with a parent cause.
Give every device a topology path and detect "many children, one cause":
def group_by_topology(events: list[dict], window_s: float = 120) -> list[dict]:
"""Fold events that share an upstream ancestor into a single group event."""
events = sorted(events, key=lambda e: e["ts"])
groups: dict[str, list[dict]] = {}
for e in events:
# group key = nearest ancestor that is itself alarming, else the device's parent
groups.setdefault(e.get("parent_id") or e["device_id"], []).append(e)
out = []
for parent, members in groups.items():
if len(members) == 1:
out.append(members[0])
continue
span = members[-1]["ts"] - members[0]["ts"]
if span > window_s:
out.extend(members) # not a burst, do not merge
continue
out.append({
"rule_id": "cascade.grouped",
"severity": max((m["severity"] for m in members), key=_rank),
"device_id": parent,
"entity": "group",
"ts": members[0]["ts"],
"count": len(members),
"members": [m["fingerprint"] for m in members],
"summary": f"{len(members)} alerts under {parent} within {int(span)}s",
})
return out
The important guard is span > window_s. Without it, you eventually merge two genuinely separate incidents that happen to share a parent, and the operator loses information. Grouping must be time-local.
Stale-cascade detection is the companion technique: if a device's children all go quiet at the same moment, that is not "everything recovered", it is a communication failure. Track expected_report_interval per device and emit a single device.silent when it is exceeded, rather than letting each downstream rule time out independently.
Layer 3: Flap damping
Flapping is a condition that crosses the threshold repeatedly: on, off, on, off, every few seconds. It produces a stream of resolved and re-raised alerts that is worse than a steady alarm, because each transition may trigger notifications.
Damp it at the source, before the rule fires:
class FlapDampener:
def __init__(self, n_on=3, n_off=3, decay_s=300):
self.n_on, self.n_off, self.decay_s = n_on, n_off, decay_s
self.on_count = self.off_count = 0
self.state = False
def observe(self, raw: bool) -> bool:
if raw:
self.on_count, self.off_count = self.on_count + 1, 0
if not self.state and self.on_count >= self.n_on:
self.state = True
else:
self.on_count, self.off_count = 0, self.off_count + 1
if self.state and self.off_count >= self.n_off:
self.state = False
return self.state
Requiring three consecutive samples in each direction turns a 40-transition-per-minute flapper into one clear state change. It costs detection latency equal to n_on × sample_interval — trivial for temperature, and something you must budget explicitly for fast signals.
If the underlying signal genuinely hovers at the threshold, damping hides a real condition. The right fix is then hysteresis (raise at 80, clear at 65) rather than more damping, which is the subject of the next post.
Layer 4: Per-device rate limiting
Even after dedup and grouping, a device with a bad sensor can emit a dozen distinct rules in a loop. Apply a token bucket per device, per severity:
import time
class TokenBucket:
def __init__(self, capacity: int, refill_per_s: float):
self.capacity = capacity
self.tokens = float(capacity)
self.refill = refill_per_s
self.ts = time.monotonic()
def allow(self) -> bool:
now = time.monotonic()
self.tokens = min(self.capacity, self.tokens + (now - self.ts) * self.refill)
self.ts = now
if self.tokens >= 1:
self.tokens -= 1
return True
return False
# 5 bursts, then 1 per 10 minutes, for the "info" and "warn" tiers
bucket = TokenBucket(capacity=5, refill_per_s=1 / 600)
Never rate-limit safety or the highest severity tier. Throttling a critical alert because a device was noisy earlier is how you turn a noise problem into an outage.
When the bucket is empty, do not silently drop. Aggregate dropped alerts into a periodic summary ("dev-4711: 214 suppressed alerts, 3 rule types") so the volume itself becomes visible instead of disappearing.
Layer 5: Suppression by known state
Three state sources eliminate a large fraction of "correct but useless" alerts:
- Maintenance window. A technician is already working on it. Suppress, but keep recording.
-
Planned mode. A compressor in
defrostlegitimately exceeds the temperature threshold. Context-gate the rule. - Known-bad inventory. A device with a known failed sensor that is scheduled for replacement should be flagged once and then silenced until the work order closes.
def is_suppressed(ev: dict, device_state: dict, now: float) -> tuple[bool, str]:
if device_state.get("maintenance_until", 0) > now:
return True, "maintenance"
if ev["rule_id"] in device_state.get("suppressed_rules", ()):
return True, "manual_suppression"
if device_state.get("mode") in ev.get("ignore_in_modes", ()):
return True, "mode_gated"
return False, ""
Suppression without an audit trail is how alerts vanish and nobody notices. Every suppressed event should increment a counter and appear in a daily report.
Layer 6: Digest instead of interrupt
Not every alert deserves an interruption. Split the tiers explicitly:
| Tier | Delivery | Latency | Rate |
|---|---|---|---|
safety |
page, plus interlock | immediate | unthrottled |
critical |
page | < 60 s | token bucket |
warn |
chat channel, threaded | < 5 min | grouped per device |
info |
daily digest | next morning | batched |
Batching info into a morning digest with counts per rule type is usually the single easiest win. It removes thousands of events from the interrupt path while losing no information.
The result, and the thing that surprised me
After the six layers, the same fleet produced ~1,150 events/day against 26 incidents/day — about 44 per incident, down from 540. The 92% reduction was distributed roughly as:
| Layer | Share of reduction |
|---|---|
| Fingerprint dedup | 41% |
| Cascade grouping | 22% |
| Flap damping | 14% |
| Mode/maintenance suppression | 12% |
| Rate limiting | 8% |
| Digesting | 3% |
The surprise was the third row. Flap damping removed more noise than I expected, because a single oscillating sensor can generate more events than a dozen healthy ones combined.
The other surprise was the effect on trust. Once the alert stream was small enough to read, operators started replying to alerts with judgments — "that's the seal again" — which became the labelled data that later improved the model. Noise reduction was a prerequisite for ever getting useful feedback.
Implementation order if you are starting today
- Fingerprinting and per-fingerprint state (a day of work, the biggest single win)
- Severity tiers with muting on parent faults
- Maintenance and mode suppression (needs process knowledge, not code)
- Flap damping with three-sample confirmation
- Topology grouping with a time window
- Rate limiting and digests
Resist starting with 5 and 6. Grouping is the most intellectually interesting layer and the least valuable per unit of effort — and it is useless if the same fingerprint is still lighting up 200 times a day.
Next: Thresholds, Hysteresis, and Hold-Downs — Alert Logic Operators Actually Trust.
Top comments (0)