#42 - Prometheus - a practitioner take
A Helm install makes metrics easy to collect; keeping Prometheus alive takes curation.
16 min read
If you follow CloudNative hype wave, you might feel that Prometheus is the must-use monitoring tool for everything CloudNative. Plus, almost everything nowadays has a Prometheus exporter. Just get that helm chart installed, and here you go - metrics question sorted out. Want to monitor endpoints - here is BlackBox exporter for you. Want to get notifications - AlertManager got you covered. And so on and so on. But is it all rainbows and unicorns? You probably guessed that it depends. This time, Semyon is joining us to air his grievances with Prometheus and share insights on how to cook it if you decide to go down this route.
Prometheus ships with no limit on cardinality
You install the chart and a minute later you have metrics for everything in the cluster: nodes, pods, containers, the control plane, every exporter anyone ever added. Dashboards fill themselves in. Nobody had to instrument anything. Then, weeks or months later, the Prometheus pod gets OOMKilled, comes back, replays its write-ahead log, and dies again. Or it stays up until somebody opens Grafana, runs one query over the wrong metric, and kills it from the query side.
This isn’t a misconfiguration you can grep for. Prometheus keeps one time series per unique combination of metric name and label values, series cost memory, and the defaults put no ceiling on how many series a target is allowed to hand over. Something has to select that target first, through your scrape config or your service discovery. Once it is selected, whoever controls it can add a label with an unbounded set of values, and the series count climbs with no help from you.
Semyon Novikov is a systems engineer and SRE working as an independent contractor. He moved into operations from development around five or six years ago, and ran monitoring on Riemann, InfluxDB and Graphite before Prometheus turned up in his life. He’s careful to say he’s no Prometheus expert, and that’s the point: this is the view from someone making the thing work on a budget rather than studying it. What he knows about Prometheus he learned either by being hit with it or by finally reading Prometheus: Up & Running after being hit too many times.
What Prometheus was built for
Start with what it’s good at, because every failure below follows from it.
What problem was Prometheus built to solve?
Monitoring, alerting and dashboards for a fleet of microservices, with a dimensional data model and a query language, on servers that each hold their own data.
SoundCloud’s own write-up from January 2015 says the team hit “serious limitations” with its StatsD and Graphite setup as it moved to microservices, and wanted a multi-dimensional data model, a real query language and operational simplicity instead. What came out of that stores data on local disk on each server and deliberately avoids distributed storage, which the authors said “demand payment in complexity and operational burdens”. SoundCloud kept several weeks or months of data without downsampling. Durable long-term storage, they wrote, needs a distributed backend.
PromQL and the dimensional data model are as good as people say, and they do things Graphite can’t. What pays for them is space, on local disk, on one machine.
The defaults still say so. Local storage keeps 15 days unless you tell it otherwise with --storage.tsdb.retention.time. Almost nobody uses it that way. It gets installed as a drop-in replacement for whatever came before, with the expectation of retention, window functions, and a comparison between this hour’s HTTP 500 rate and the same hour three years ago. PromQL can express that comparison: offset has been there from the start, and the @ modifier arrived in 2021. What it needs is three years of samples still on a disk you can query, and the single-node design doesn’t hand you that.
Cardinality, and why the defaults don’t save you
The gap between those two uses shows up first as memory.
What is cardinality, and why does it kill a Prometheus server?
Cardinality is the number of distinct values a label takes in your setup, and because every distinct combination of label values is a separate time series, a few labels multiply into a series count nothing caps.
status_code with five values and method with four is twenty series. Adding user_id allows up to twenty series per user, before other labels multiply that further, and the series stay after those users are gone. The docs say it plainly: “Remember that every unique combination of key-value label pairs represents a new time series, which can dramatically increase the amount of data stored”, followed by “Do not use labels to store dimensions with high cardinality … such as user IDs, email addresses, or other unbounded sets of values.” That’s guidance for whoever writes the instrumentation. It isn’t enforcement, and the server ships with none.
A fresh install of the kube-prometheus stack pulls tens of thousands of metrics out of a Kubernetes cluster before you instrument a single service of your own, and some of them carry labels with uncapped values. We’ve seen systemd slice ids in there. Nothing warns you, and the thing looks like it’s working, which is the worst version of this.
Prometheus will at least show you where you stand: the TSDB Status page in the web UI reads /api/v1/status/tsdb, which returns cardinality statistics for the head block: seriesCountByMetricName ranks metrics by series, and labelValueCountByLabelName gives the distinct-value count per label.
Ingestion isn’t the only way it dies either. Prometheus memory-maps the head chunks it keeps on disk, so a PromQL query against a high-cardinality metric has to pull more of that data into RAM to answer. The scrape fills the memory and the query that reads it finishes the job.
Out of memory is expected behaviour
The obvious objection is that none of this is Prometheus’s fault. Don’t put unbounded labels on metrics and you won’t have the problem.
What do the maintainers say when it happens to you?
That it’s expected behaviour, and given the design they’re defending, it is.
Issue 3780, opened in February 2018, is the canonical example: Prometheus 2.0.0, 24 GB of RAM, eight cores, roughly 50 million short-lived series, out of memory about ten minutes after start. Brian Brazil, a Prometheus maintainer and the author of the book above, answered the same day: “Prometheus is not an event logging system, and attempting to use it that way will result in issues as you have discovered.” He put the workload at 200 GB of RAM minimum, pointed at the ELK stack instead, and closed the issue as expected behaviour.
He’s right on the facts and the operator is still standing where they started. There’s a second assumption buried in the design: whoever runs Prometheus also runs the software it monitors. On a platform team that isn’t true. A developer who labels a counter with a request id has no idea they just took down cluster monitoring, and anyone who wanted to do it on purpose needs a small HTTP server that puts a random value in a label.
Levers do exist, and they’re off by default. sample_limit caps the samples accepted from one scrape, label_limit and the label length limits cap the rest, and each defaults to 0: no limit. Go over one and that whole scrape fails, so the noisy target goes dark instead of the server that watches everything else.
Take that cover for what it is. A target that stays under the cap while rotating its label values keeps adding series, and compliant targets still sum to an ingestion rate one server has to hold. What decides whether the server lives is the total series count against the RAM you gave it, and a bounded label can clear that on its own: the instrumentation guidance works through a quota metric per user, 10,000 users on 10,000 nodes, bounded, finite and still “too much for the current implementation of Prometheus”.
Retention is a single-node problem
Memory is the loud failure. Retention is the quiet one, and it arrives the first time somebody asks a question about last year.
How do you keep a year of metrics in Prometheus?
You raise --storage.tsdb.retention.time and give the server the disk for it, then decide whether one node is where a year of history should live.
Capacity you can work out in advance: the storage docs put it at retention times ingestion rate times one to two bytes per sample. Durability you can’t. The storage docs tell you to treat local storage as a single-node database, note that it “is not clustered or replicated”, and say it “is not arbitrarily scalable or durable in the face of drive or node outages”. One disk takes the year with it. Remote write and remote read exist to move the samples to something built for the job, and the docs warn that remote systems “vary greatly in durability, performance, and efficiency”.
Thanos is the usual answer for a global view across clusters. It queries several Prometheus servers at once, keeps blocks in the object storage of your choice “for unlimited time”, and downsamples history so long-range queries stay fast. Deployment is where people get stuck. One route is Jsonnet, a superset of JSON with functions, where the templates take a lot of massaging; the v0.25 getting started guide also lists community Helm charts and Prometheus Operator support, so that’s a choice rather than the price of entry. The object storage bill isn’t only bytes either: you pay per thousand GET requests, and a bucket full of small blocks racks those up quickly.
Price it per question instead. This hour’s error rate against the same hour three years ago is a reporting question, and the store that answers it gets picked on three things: how long the data has to be kept, which queries will run against it, and what each candidate costs at your volumes.
Collect less, and start from an empty scrape config
All of which points at one lever that’s cheaper than any of the architecture above.
What is the one change that keeps a Prometheus server alive?
Collect fewer metrics at the source instead of dropping them after they arrive.
Worth separating what that aims at. The Prometheus Operator is a controller: it “uses Kubernetes custom resources to simplify the deployment and configuration of Prometheus”, and it configures Prometheus to scrape whatever your ServiceMonitor and PodMonitor objects select. What arrives already selecting most of a cluster is the stack shipped around it. kube-prometheus is, in the project’s own words, “example configurations for a complete cluster monitoring stack”, exporters and alerting rules included, and the community Helm chart offers much the same. You can keep the Operator and still curate: drop the bundled monitors, write your own, name the targets and the metrics you intend to query.
Building that config yourself is real work up front, and after that it’s a line of review per new service. metric_relabel_configs can drop metrics after the scrape and it does help memory, but you’ve already paid to expose, transfer and parse them. If you don’t run StatefulSets, don’t collect StatefulSet metrics.
Curation doesn’t happen unless somebody owns it. Monitoring is a project running beside the one you’re shipping: it goes on the board, it gets reviewed, people get taught how to use it. The test we keep coming back to is the blunt one. Are we making money right now? If the answer is no, that’s the thing to work on, and every metric that can’t be traced back to that question is a candidate for deletion. The stack needs the same treatment as the services it watches, its own monitoring and its own retention included, or you find out it stopped collecting on the morning you need it.
Managed Prometheus, and what it actually moves
Which brings us to the option most teams should take, and the one point where we don’t agree.
Does a managed service fix the cardinality problem?
It moves storage and queries off your pager, leaves the cardinality on your invoice, and leaves you running whatever does the scraping.
Semyon Novikov’s answer to “how do you scale Prometheus” is to buy Amazon Managed Service for Prometheus, GA since September 2021, and stop thinking about it. Andrey’s objection is that it leaves high cardinality exactly where it was.
AMP doesn’t scrape your cluster. It accepts remote write, and AWS’s own getting-started guide has you deploy and manage a Prometheus server or an OpenTelemetry agent to do the collecting. Prometheus pulls, so whatever collects has to reach every endpoint it scrapes, which upstream turns into advice to “run Prometheus servers on the same network as the monitored instances”. In a multi-tenant cluster whose tenants are isolated from each other, that’s an ingress question per tenant. Ingestion, long-term storage, query execution and the rules move across. Scrape capacity, the memory of whatever is scraping, and the monitoring of both stay with you.
AWS prices AMP “based on metric samples ingested, metrics and metric samples stored, and query execution time”, with ingestion at $0.90 per 10 million samples for the first two billion since the May 2021 price cut. A metric nobody looks at costs you on ingestion and on storage instead of killing a pod, and adds query time whenever a dashboard or a recording rule sweeps it up.
Our own numbers show why the argument matters. Before: one Prometheus per environment, 32 GB of RAM, 500 GB SSDs, out of memory all the time, losing persistent volume claims all the time. After, with the metrics curated down first: around ten dollars a month. The block storage on its own used to cost more than that. Your mileage will differ, and so does the price list: Google Cloud’s Managed Service for Prometheus reached GA in March 2022 priced per sample ingested, with two years of retention included.
Mimir, VictoriaMetrics, and Prometheus as an interface
Buying the managed version isn’t the only way to get your history off a single local disk.
What else can hold the data behind Prometheus?
Projects that speak Prometheus at both ends, one of them announced weeks ago and one of them three years old.
Grafana Labs introduced Grafana Mimir at the end of March 2022: an AGPLv3 fork of Cortex that claims to “scale to 1 billion metrics” and is Prometheus compatible including remote write, PromQL and alerting. If you’re running Thanos and fighting its Jsonnet, it’s the first thing to look at. VictoriaMetrics is not a new arrival beside it: the single-node version was open-sourced in May 2019, three years before Mimir was announced, and it also ingests Graphite, InfluxDB, OpenTSDB and CSV formats. Its performance numbers are the maintainers’ own benchmarks, so treat them as claims, not as measurements from your workload. We know teams who swapped Prometheus out for it and got on with their lives.
They are not the same shape, and the shape is what you sign up to operate. Mimir inherits Cortex’s: separate components, a compactor, a query frontend, a ruler and an Alertmanager among them, over object storage, with version 2.0 supporting “AWS S3, GCS, Azure Blob Storage, OpenStack Swift, as well as any S3-compatible object storage”. Single-node VictoriaMetrics is one binary with no cluster and no bucket: “all the data is stored in a single directory specified by the -storageDataPath command-line flag”, and object storage comes in only if you archive snapshots to it. Its cluster version splits into vminsert, vmselect and vmstorage when one node stops being enough. Self-hosting either leaves the database operations with your team: processes to run, disks or buckets to pay for, upgrades to land.
The pattern matters more than either product. Prometheus is becoming an interface: the exposition format every library ships with, plus PromQL, with somebody else’s storage underneath. One level up, OpenTelemetry is standardising logs, metrics and traces, with its metrics implementations reaching release candidate in May 2022. Being the standard is why you can’t avoid Prometheus on a cloud-native stack, and why the storage underneath it is a choice now, including the choice to let somebody else operate it.
What this means for teams
None of this needs a migration. It needs somebody to look at what you’re collecting and decide what you’d miss.
This week:
- Open TSDB Status in your Prometheus and write down the metrics with the most series and the labels with the most distinct values. Treat that as a shortlist: for each line, ask whether the set churns as pods and requests come and go, and whether anyone queried it this month. A bounded
status_codeearns its place. A request id or a systemd slice name usually doesn’t. - Set
sample_limiton every scrape job, knowing it caps one scrape rather than your series count, and that the query path is still open. - Add up what your current setup costs in instances and block storage, then price the managed version on every line your provider charges, the collectors you would keep running yourself included. Do it before the next instance resize, not after.
- Name the system where year-old metrics live, and read the retention flag on the server instead of assuming it. If the answer is one Prometheus on one local disk, that’s the durability the whole year has.
Common questions, answered
How do I stop my Prometheus pod from being OOMKilled?
Cut the number of series before they reach the server. Stop scraping metrics you never query, and set sample_limit on each scrape job so a target that explodes inside one scrape fails on its own. That cap is per scrape, so it misses a target that stays under it while rotating label values, and it does nothing about a wide query. More RAM buys time rather than a fix: if the label behind the growth is unbounded, the next restart lands on a bigger instance with the same ending.
How do I find which metrics are using all the memory?
Use the TSDB Status page in the Prometheus web UI, or /api/v1/status/tsdb if you’d rather script it. It ranks the head block by series count per metric name and by distinct values per label name. The top entries are usually metrics carrying an identifier, a URL path or a container id. A bounded label with thousands of values can fill the memory on its own, so judge each line by total series against the RAM you have, then fix the worst at the source.
Is managed Prometheus cheaper than running it yourself?
It depends on what you collect, because these services bill per sample rather than per instance you size once. Amazon Managed Service for Prometheus charges for samples ingested, metrics and samples stored, and query execution time; Google’s prices per sample with retention included. A curated setup of ours landed around ten dollars a month, less than the block storage it replaced. Compare like for like: instances, block storage and hours self-hosted, against your provider’s own charges plus the scrapers you keep running. Curate either way.
Related episodes
- Monitoring Done Wrong or Dreaming for a Better Monitoring: what sane monitoring defaults would look like, and why every project rebuilds the same boilerplate.
- Three pillars of observability: logs, metrics and traces, where to start, and why debugging from logs gets expensive.
- How Do We Run Kubernetes In The Cloud?: the managed-versus-self-hosted argument one layer below this one.
Resources
- Prometheus: Monitoring at SoundCloud: the design goals, the local-storage decision and the retention it was built for.
- Metric and label naming: the official warning about high-cardinality labels, with examples.
- Instrumentation: do not overuse labels: what each labelset costs, and a bounded label set Prometheus still can’t hold.
- Prometheus OOM for lots of short time series: where out-of-memory death is confirmed as expected behaviour.
- Storage: retention defaults, the capacity formula, and what local storage promises about durability.
- TSDB stats API: the endpoint behind the TSDB Status page, and what it counts.
- Single-node VictoriaMetrics: the on-disk layout and flags, and why it needs neither a cluster nor a bucket.
- Semyon Novikov: our guest’s site, with his CV and the open source he publishes as
nvkv.
Since we recorded
Native histograms landed as an experimental feature in Prometheus 2.40 in November 2022, and experimental OTLP ingestion in 2.47 in September 2023, both carried forward into Prometheus 3.0 in November 2024 alongside Remote-Write 2.0. AWS raised the default active series limit per Amazon Managed Service for Prometheus workspace from 10 million to 50 million in July 2025, with up to a billion on request. We came back to the trace side of the stack in Tracing explained, and to the self-hosted-versus-managed bill in K8s vs Managed Services.
