The first nine posts built a pipeline. This one is about keeping it alive for three years, through sensor replacements, process changes, model updates, and staff turnover.

Most IoT ML systems do not die from a bad model. They die from unwatched drift — a slow change in the data that nobody measures — followed by a period of firing on everything, followed by muting, followed by an incident nobody saw coming.

Four layers of metrics, and why you need all four

Alert metrics alone tell you when it is too late. Model metrics alone tell you nothing about the process. Watch all four:

Layer Examples Answers
Data quality sample rate, gap ratio, out-of-range ratio, clock skew, sensor disagreement Is the input trustworthy?
Model score distribution, alarm rate, calibration error, inference latency, feature drift Is the model behaving as designed?
Alert volume per day, severity mix, dedup ratio, time-to-ack, disposition rate Is the alert stream useful?
Business incidents caught, lead time, unplanned downtime, dispatches avoided, false dispatch cost Is it worth running?

The layering matters because failures cascade upward: a sensor that starts returning a constant value (data quality) shifts the score distribution (model), which produces continuous low-severity alerts (alert), which a technician eventually ignores (business). If you only watch the alert layer, you see the symptom three layers downstream and treat it as an alert-tuning problem — which is how thresholds get loosened to hide a broken sensor.

Data quality first, always

Three checks catch the majority of real incidents, and they are cheap enough to run on every device:

import numpy as np def data_quality(series: np.ndarray, expected_hz: float, nominal_range: tuple[float, float]) -> dict: lo, hi = nominal_range d = np.diff(series) return { "n": len(series), "gap_ratio": float(np.mean(np.abs(d) > 3 / expected_hz)) if len(d) else 0.0, "flatline": float(np.mean(d == 0)) > 0.98, "out_of_range_ratio": float(np.mean((series < lo) | (series > hi))), "stuck_high": float(np.mean(series >= hi)), "quantization_step": float(np.min(np.abs(d[d != 0]))) if np.any(d != 0) else 0.0, } 

quantization_step is the sleeper. A sensor whose smallest observable change suddenly doubles has lost a bit — usually ADC range corruption or a firmware change — and its variance features are now wrong in a way no model metric will reveal as such.

flatline catches the most common field failure of all: a sensor that is still transmitting, still on time, still in range, and constant. Every model that consumes it will produce "normal" with high confidence.

Drift detection that respects equipment seasonality

Covariate shift detection on features is standard: compare a reference window to a recent window with a population stability index (PSI) or a Kolmogorov–Smirnov statistic.

def psi(reference: np.ndarray, current: np.ndarray, bins: int = 10) -> float: edges = np.quantile(reference, np.linspace(0, 1, bins + 1)) edges = np.unique(edges) if len(edges) < 3: return 0.0 ref = np.histogram(reference, bins=edges)[0] / len(reference) + 1e-6 cur = np.histogram(current, bins=edges)[0] / len(current) + 1e-6 return float(np.sum((cur - ref) * np.log(cur / ref))) def drift_report(ref: dict[str, np.ndarray], cur: dict[str, np.ndarray]) -> dict: out = {} for k in ref: p = psi(ref[k], cur[k]) out[k] = {"psi": round(p, 4), "level": "high" if p > 0.25 else "watch" if p > 0.1 else "ok"} return out 

The thresholds (0.1 watch, 0.25 act) come from credit-risk practice and transfer reasonably. The hard part is not the statistic — it is what you compare against.

Naive drift detection compares this week to last week and alerts constantly, because industrial equipment is seasonal: summer ambient temperatures shift everything, production schedules change weekly, and machines cycle through modes. Three practices fix this:

  1. Compare like with like. Condition the reference window on operating mode and load bucket. Drift within the run × high-load bucket is meaningful; drift caused by a change in the mode mix is not.
  2. Use a rolling seasonal baseline. Compare against the same period 4 weeks ago and against a long-run reference; report both.
  3. Require persistence. Two consecutive weekly windows above threshold before acting. A single week of drift is usually a schedule change.

The label loop is the real MLOps work

Models degrade because reality changes, and you find out through labels. In IoT, labels come from maintenance records, which are late, sparse, and inconsistent.

Three things make the loop function:

Join alerts to work orders. For every alert, record whether a work order was opened within N hours for the same device, and whether the technician confirmed the fault. Even at 40% coverage, this gives you a calibration signal.

def disposition_join(alerts: list[dict], work_orders: list[dict], window_h: int = 48) -> list[dict]: out = [] for a in alerts: t0, t1 = a["ts"], a["ts"] + window_h * 3600 match = next((w for w in work_orders if w["device_id"] == a["device_id"] and t0 <= w["ts"] <= t1), None) out.append({**a, "disposition": match.get("confirmation", "unknown") if match else "no_action", "work_order": match["id"] if match else None}) return out 

Make "no action taken" a first-class label. It is the majority class and the most honest signal about precision. Track the share of alerts with no follow-up — that is your false-positive proxy, and it is usually higher than anyone assumes.

Sample for review deliberately. Do not review the alerts that already look interesting. Sample uniformly from the warn tier weekly; the bias in self-selected review is what makes teams believe their precision is 70% when it is 30%.

Retraining: three triggers, one of them automated

Trigger Signal Automation
Scheduled Calendar, e.g. quarterly Automate the pipeline run, require human promotion
Drift PSI high on key features for 2 consecutive weeks Open a ticket automatically
Performance Precision drop below budget on joined labels Open a ticket automatically

Automate the trigger, never the promotion. A model that promotes itself on a noisy metric is a slow-motion outage. Promotion goes through the shadow-mode and canary gates from the previous post.

Distinguish recall drift from precision drift when deciding what to do:

  • Precision falling (more false alarms) is usually population drift and is fixed by retraining or re-thresholding.
  • Recall falling (missing faults) with stable precision usually means the failure mode itself changed — new equipment, new process — and retraining on old data will not help. You need new labels for the new mode.

The second case is common and almost always misdiagnosed as "the model needs retraining".

SLOs for the monitoring pipeline itself

Your alerting system is a production service. Give it SLOs, or it will fail silently:

ingest delay p95 < 30 s from device timestamp to platform alert evaluation delay p95 < 60 s from window close to decision notification delivery p99 < 120 s from decision to page data completeness > 99.5% of expected device-minutes present model availability > 99.9% of devices running a supported version 

The one people forget is data completeness. A pipeline where 8% of devices are silently dropping data looks healthy on every latency metric and produces confidently wrong fleet aggregates.

Alert on the absence of data as loudly as on bad data. A device that has reported nothing for 3× its expected interval is an incident, not a gap to be filled by the next message.

The quarterly review that keeps the system alive

Put six questions on a recurring calendar. Without them, the system decays in a predictable way:

  1. Which rules have not fired in 90 days? (Delete or fix.)
  2. What is the alert disposition rate, and is it trending?
  3. Which devices are on unsupported model or firmware versions?
  4. Is the false-alarm budget still the budget the team wants?
  5. What did we miss, and was it a data, model, threshold, or routing failure?
  6. What is the cost per incident caught, and is it going down?

Question 5 is the most important and the least likely to be scheduled. Every missed incident should produce one line in a log: which layer failed. After a year, that log tells you where to invest, and it is the only reliable input to "should we replace the model" — a question that otherwise gets answered by whoever is loudest in the meeting.

Closing the series

The shape of a system that survives contact with a real fleet:

device : hard limits, feature extraction, ring buffer gateway : baseline gate → model on flagged windows → rule engine → dedup/damping cloud : correlation, triage, tickets, drift, retraining ops : alert budget, disposition loop, quarterly review 

Every layer exists because a simpler version failed in a specific, observable way: hard limits because models can be wrong; the baseline gate because models are expensive; the rule engine because policy is not learnable; dedup because operators mute noisy systems; shadow mode because rollouts go wrong; the drift loop because reality moves.

None of it is exotic. The hard part is deciding, per decision, which tier it belongs on — the question this series started with.

Thanks for reading. If you build something from this, the four numbers worth writing down first are: the deadline, the history required, the update cadence, and the cost of a false positive.