IoT Alert Rules: Hysteresis, Persistence and Stale Data
A threshold crossing should begin a defined decision, not an endless stream of notifications. A useful sensor alert specifies how the condition begins, when it clears, what missing data mean and who acts. These choices belong in the design before the first notification reaches an operator.

The following temperature example is an invented advisory rule for a noncritical equipment cabinet. Its thresholds are teaching values, not equipment limits, food-safety guidance or a protective control system. The method is useful precisely because its assumptions and state transitions can be tested.
Separate four decisions
A measured value can cross a threshold while the application is still waiting for confirmation. An alert can remain active after someone acknowledges it. A value can return to normal while the application has no fresh evidence that it stayed there. Treating all of these situations as one red-or-green flag makes the workflow ambiguous.
| Decision | Question | Constructed choice |
|---|---|---|
| Entry | What evidence starts an active condition? | Three consecutive scheduled valid samples at or above 30°C |
| Clearance | What evidence ends it? | A fresh valid sample at or below 28°C |
| Freshness | When is the evidence too old? | More than twelve minutes since the last valid acquisition |
| Response | What does acknowledgment change? | Task ownership, without changing the measured condition |
The rule assumes one scheduled sample every five minutes and a means to identify those samples. “Consecutive” means consecutive expected slots, not simply the last three records that happened to arrive. A missing or invalid expected sample breaks the pending sequence in this example. It must not be skipped silently to manufacture apparent persistence.
Walk through the state changes
| Time | Temperature | Condition after evaluation | Reason |
|---|---|---|---|
| 10:00 | 29.0°C | Normal | No active entry sequence |
| 10:05 | 30.2°C | Pending: 1 | First qualifying scheduled sample |
| 10:10 | 30.4°C | Pending: 2 | Second consecutive qualifying sample |
| 10:15 | 30.1°C | Active | Third qualifying sample |
| 10:20 | 29.0°C | Active | Above the 28°C clearance threshold |
| 10:25 | 27.8°C | Normal | Fresh sample satisfies clearance |
The first and third qualifying samples are ten minutes apart. Three five-minute samples do not prove fifteen minutes above the threshold, and they do not prove the temperature remained above it between samples. This is a sampled-evidence rule. If continuous duration matters, the sensing and local event-recording requirements must support that claim.
Use hysteresis for the specific problem it solves
The gap between the entry and clearance thresholds creates hysteresis. Once active, the example stays active at 29°C instead of repeatedly entering and clearing around 30°C. While normal, a reading in that gap does not activate it. The current state therefore helps determine the next state.
Hysteresis and persistence address different issues. Hysteresis separates the entry and exit boundaries. Persistence asks for repeated or sustained evidence before changing state. Prometheus’s documented pending and firing behavior illustrates duration-based evaluation, but the three-sample rule here is our own application design, not an equivalent Prometheus configuration.
Do not increase the gap or waiting period merely to make a noisy dashboard quiet. That can delay a useful response or conceal an unsuitable sensor position. Examine measurement quality, event frequency and the cost of delayed action first. The installation survey guide helps isolate physical deployment differences from application behavior.
Keep freshness separate from condition
If the last valid sample is acquired at 10:25, the example becomes stale after 10:37. At 10:38, the display should say that the latest valid condition is old. It should not invent a new normal sample. If the last established condition had been active, silence would not count as evidence that it cleared.
Represent these as separate dimensions: the last established condition and the freshness of the evidence. That allows a useful display such as “last condition active; current evidence unavailable.” Decide whether a separate data-availability task is needed and who owns it. Avoid repeatedly sending the same process alert just because no new data have arrived.
The timeout must use a defensible time basis. An old observation arriving now does not reset acquisition freshness to zero. Follow the distinction between acquisition and receipt in the timestamp guide. If acquisition time is unknown, state that limitation and use a separately named receipt-based availability rule.
Make notification a controlled consequence
Create a stable identity for an alert episode, for example an asset, rule version and the event that activated it. Repeated delivery of that event should not create more work orders. The callback ingestion guide explains why duplicate protection belongs at both storage and action boundaries.
- Acknowledged: someone has accepted responsibility for investigation.
- Condition cleared: fresh evidence satisfies the clearance rule.
- Task closed: the operating process records its final disposition.
Those statuses may occur at different times. If an operator acknowledges an active condition, the sensor should not be relabeled normal. If the condition clears before anyone responds, the task may still require review, depending on its purpose. Write this policy in the runbook rather than leaving it to the color of a button.
Test boundary values and interruptions
Include exactly 30°C and exactly 28°C in the test vectors because the chosen comparisons include equality. Test a missing middle sample, a duplicate, an out-of-order observation and a restart while pending. Specify whether pending state survives a service restart and how stored history is used to reconstruct it.
Finally, review an episode with the person expected to respond. The notification should identify the asset, condition, evidence time and intended action. If that person cannot tell what to do, adding more accurate threshold arithmetic will not fix the operating gap. A good alert rule is a small, explicit agreement between measurement, software and work.