On a Tuesday morning at the end of April, at the office in İzmir, before I'd even poured my coffee, a message came in from the NOC team: "Grafana won't open, the panels are timing out." I looked not at the panels but at the Prometheus behind them: memory usage had climbed from 6 GB to 38 GB, and the pod had gone into an OOMKilled loop. Every restart meant a 14-minute WAL replay, and for those 14 minutes we could see nothing at all about more than 10,000 devices in the field. The monitoring system had collapsed, and the bitter irony was this: what brought it down wasn't the system it was monitoring, but the very way we were monitoring it.
When I looked at our active time series count, I read the number twice: 11.4 million. Three weeks earlier it had been 480,000. We hadn't added any new devices in the field. So where had these 11 million series come from?
Every Label Is a Multiplier
In Prometheus, a metric name on its own is cheap; what's expensive is label combinations. Every unique set of labels is a separate time series, and every series lives in memory with its own index entry and its own chunks. The moment you say "let's add a device_id label so we can see things per device," 10,000 devices give you 10,000 series. Add firmware_version (there were 14 different versions running in the field) and the theoretical space goes up to 140,000. Then come region, model, sim_operator, and the multipliers start stacking on top of each other. We'd kept this multiplication under control for years; 480,000 series with 6 GB of memory was a perfectly livable balance.
What broke the balance was an innocent-looking line that went into the gateway software two sprints earlier. To diagnose connection problems better, a developer on the team had added a connection_id label to the MQTT session metrics — an identifier in UUID format, regenerated for every TCP session. On stable connections this label produced only a handful of values, and that's how it had looked in testing too. But in the field there were hundreds of devices dropping to 2G, disconnecting and reconnecting every five minutes. Every reconnect meant a new UUID, and every UUID meant a new series. The cranky regions, with more than 200 reconnects per device per day, had spawned millions of dead series on their own.

The Innocents We Took for Culprits
Of course, we looked in the wrong places first. The first hypothesis was Grafana: "Someone must have built a heavy dashboard that queries every panel every 10 seconds." We went through the query logs; there were heavy queries, but they didn't explain the memory growth — query load burns CPU, it doesn't cause persistent memory bloat. The second hypothesis was retention: "The disk must be full and compaction is stuck." There was a delay in the TSDB compaction logs, but it was a consequence, not the cause. We went around in circles for almost half a day, mistaking symptoms for causes.
What led us to the right place was Prometheus's own TSDB statistics. When we looked at the "highest cardinality labels" table on the status page, everything was right there on the screen: connection_id, 9.7 million unique values. The label in second place had 14,000 values. The difference in scale was so absurd that the team went quiet for a moment. A cardinality explosion doesn't require detective work; if you know where to look, the table tells you the culprit by name. We remembered where to look six hours too late.

Putting Out the Fire and Changing the System Are Different Jobs
The emergency response was simple: we added a rule to the gateways' scrape config with metric_relabel_configs that drops the connection_id label, and had the problematic metric switched off at the source. The old series would have kept living in the index for the retention period (15 days for us); instead of waiting for that, we issued tombstones for the affected metrics through the admin API, and after compaction memory dropped to 9 GB. By the next morning the panels were opening. But that week I knew this wasn't the real job, and that the same movie would be reshot with a different label.
The permanent solution consisted of three layers. The first is a label budget: an internal rule that estimates and caps the maximum number of series for every metric. A developer who wants to add a new label has to write the number of values that label can take in the PR description. UUIDs, session IDs, user IDs, full URLs, error message text — none of these can be labels; this is now a written rule, and there's a metrics lint check in CI.
The second was honestly acknowledging the need for per-device observation. Saying "don't keep per-device metrics" is easy, but when the field team wants to see a single device's signal history, you need to have an answer. We took per-device raw telemetry out of Prometheus entirely and left it in TimescaleDB, where it was already flowing; only fleet-level aggregates stayed in Prometheus — averages, percentiles and counters broken down by region, model and firmware version. Single-device queries now come from a separate datasource in Grafana. Our series count dropped from 480,000 to 92,000, and Prometheus memory from 6 GB to 2.1 GB; the p99 query time fell from 4.8 seconds to 700 milliseconds.
The third is early warning. We weren't monitoring the monitoring system; now we are. We have a separate panel for the active series count, the series creation rate (churn) and the 10 highest-cardinality labels, plus two alert rules: a warning if total series exceed 200,000, and a critical alert if series grow by more than 20 percent within an hour. If that innocent connection_id line were written today, the alarm would go off 40 minutes after it hit production, and the incident would close as a Slack message rather than an OOM crisis.

Along the way we also had an awakening about histograms. A Prometheus histogram looks like an innocent metric, but each one expands into as many series as it has buckets: a latency histogram with 12 buckets means 14 series per label combination (the buckets plus sum and count). An HTTP histogram on the gateways, multiplied by the endpoint and status labels, was holding 38,000 series on its own, and nobody had looked at that metric in six months. During the audit we pulled a list of "metrics not queried even once in the last 90 days"; 22 percent of all series came from metrics that weren't used in any panel or any alert. We switched them off at the source. The saying "you can't manage what you don't measure" is true; but measuring everything you glance at is a disease of its own.
Cardinality Isn't a Technical Detail; It's a Cost Item
The real lesson I took from this incident isn't technical, it's cultural. Adding a metric feels free: one line of code, an instant graph. Yet every label is a compound-interest debt paid over the lifetime of the system — it comes back as memory, disk, query time and, at the worst possible moment, operational fragility. Logs and traces are designed to handle high cardinality; metrics are built on the assumption of low cardinality. When you mix up which data belongs in which house, the house falls down.
I also learned this: cardinality explosions almost never come from bad engineering; they come from well-intentioned diagnostic efforts. The connection_id label in our case was an idea that would genuinely have been useful — what was wrong wasn't the idea but the layer we put it in. If Prometheus is bloating in your IoT fleet, the panels are slowing down and nobody can find the cause, look at the cardinality table on the TSDB status page; the answer is most likely written right there, in a single row. If you're not sure where in the table to look, reach out through the contact page and we'll look at it together in half an hour — that half hour cost us six hours and a night of blindness.
Since that Tuesday, a saying has been going around the team: "Adding a label is freedom; the label's value set is responsibility." Our dashboards are simpler now, but they've never been this fast or this reliably up.