# Prometheus Cost: Why It Gets Expensive and What to Do

> Prometheus cost grows when series count, retention, HA replicas, remote storage, query load, and operator time compound. Here's how to find the driver and cut safely.

Source: https://last9.io/blog/prometheus-cost/

Your Prometheus bill is rarely one bill. It is compute for Prometheus, disk for the TSDB, object storage for long-term data, network egress for remote writes, duplicate replicas for HA, and the engineering time needed to keep all of it reliable.

The safest way to cut Prometheus cost is not to delete labels first. Find the driver first: active series, samples, retention, replicas, query load, or operator time. Then cut the driver without removing the data you need during an incident.

## My Prometheus is getting expensive. What should I do?

If your Prometheus is getting expensive, do this in order:

1. **Measure active series** with `prometheus_tsdb_head_series` and the TSDB status page.
2. **Measure ingestion rate** with `rate(prometheus_tsdb_head_samples_appended_total[5m])`.
3. **Measure storage growth** with TSDB disk usage and your retention flags.
4. **Measure query cost** with `prometheus_engine_query_duration_seconds` (a summary with p50, p90 and p99 quantiles).
5. **Measure duplication** across HA pairs, federation tiers, remote storage, and long-term query components.
6. **Measure human work**: upgrades, failed compactions, broken remote writes, slow dashboards, and on-call time spent maintaining the monitoring stack.

The cost formula is:

```text
Prometheus cost ≈ active series × samples per series × retention × replicas
                 + remote storage and network
                 + query infrastructure
                 + operator time
```

Do not start by dropping `customer_id`, `pod`, `path`, or `tenant` labels because they look expensive. Check which dashboards, alerts, and incident workflows depend on them. A label that costs money during normal operations may save hours during an outage.

## Why Prometheus cost grows

Prometheus is free to download, but the workload it creates is not free to run. The main inputs are simple:

- **Active series:** every metric name plus unique label set.
- **Samples per second:** scrape interval multiplied by targets and series per target.
- **Retention:** how long local blocks stay on disk.
- **Replicas:** HA pairs, regional copies, federation tiers, and remote storage paths.
- **Queries:** dashboards, alerts, ad hoc PromQL, and long range scans.
- **People:** the time spent operating Prometheus and the systems around it.

Those inputs compound. A metric with high-cardinality labels does not only increase storage. It also increases memory pressure, query work, remote write volume, and the chance that you need sharding or a long-term store earlier than expected.

HA adds another multiplier. Two Prometheus replicas scrape the same targets so alerting keeps working if one replica fails. That is the correct reliability tradeoff for production, but it means you should count the duplicate ingestion and storage as part of the monitoring cost.

Long-term retention adds a different multiplier. The [Prometheus storage docs](https://prometheus.io/docs/prometheus/latest/storage/) say local storage is not intended as durable long-term storage. If you need months of data, you usually add remote storage, object storage, or another query layer. That changes the cost model from one binary and one disk into a distributed system.

## Find the cost driver before changing anything

Start with Prometheus' own metrics. They tell you whether the cost is coming from ingestion, storage, queries, or remote write pressure.

```promql
# Active series in the head block
prometheus_tsdb_head_series

# Samples ingested per second
rate(prometheus_tsdb_head_samples_appended_total[5m])

# Samples per scrape by job
topk(20, sum by (job) (scrape_samples_scraped))

# Query evaluation time, p90
prometheus_engine_query_duration_seconds{slice="inner_eval", quantile="0.9"}

# Remote write backlog
prometheus_remote_storage_samples_pending
```

Then map the symptom to the first fix:

| Symptom | Likely driver | First place to look |
|---|---|---|
| Disk fills steadily | Retention or sample volume | `--storage.tsdb.retention.time`, `--storage.tsdb.retention.size`, scrape intervals |
| Memory climbs with traffic or deploys | Active series and churn | TSDB status, `prometheus_tsdb_head_series`, top metrics by series count |
| Dashboards time out | Query shape or range scans | query log, recording rules, panel refresh interval |
| Remote storage falls behind | Remote write throughput | queue config, dropped samples, network, receiver health |
| Costs rise after HA rollout | Duplicate ingestion | replica count, long-term storage, federation, object storage |
| Engineers spend time on upgrades and outages | Operational overhead | ownership, runbooks, managed backend evaluation |

If you use Last9, our docs on [calculating usage patterns and data volume in Prometheus](/docs/how-to-calculate-usage-patterns-and-data-volume-in-prometheus/) give the PromQL queries for ingestion rate, read query rate, and total time series. Use that before you change scrape configs.

## If storage is the driver: tune retention and block growth

Keep this section narrow. We already have a detailed guide to [Prometheus data retention](https://last9.io/blog/prometheus-data-retention/); the cost decision is whether the data deserves local, high-resolution storage.

Prometheus gives you two retention levers:

```bash
prometheus \
  --storage.tsdb.retention.time=30d \
  --storage.tsdb.retention.size=200GB
```

`--storage.tsdb.retention.time` controls how long data stays on disk. `--storage.tsdb.retention.size` caps disk usage. If both are set, Prometheus removes old blocks when either limit is reached.

Choose time-based retention when operations need a predictable history window. Add size-based retention when the disk is the hard constraint. In production, set both so unexpected ingest growth does not fill the volume.

The storage cut that usually works is tiering by value:

- Keep recent, high-resolution data locally for alerts and incident dashboards.
- Reduce scrape frequency for low-value infrastructure metrics.
- Drop debug or duplicate metrics before storage.
- Send long-term data to a backend built for that retention window.

Do not extend local retention just because someone may ask a six-month question someday. That turns every scrape into a storage commitment. If older data matters, treat it as a long-term storage design, not a bigger disk on the same Prometheus instance.

## If cardinality is the driver: cut the series, not the signal

High cardinality is the fastest way to make Prometheus expensive because each unique label combination creates a new time series. A single metric with `user_id`, raw URL paths, session IDs, container IDs, or pod hashes can dominate memory and disk.

Keep this pass surgical. Our guide to [high cardinality in Prometheus](https://last9.io/blog/how-to-manage-high-cardinality-metrics-in-prometheus/) covers the full workflow; for cost triage, start with the worst metric and the worst label.

```promql
# Metrics with the most series
topk(20, count by (__name__)({__name__=~".+"}))

# Jobs and metric names driving series count
topk(20, count by (job, __name__)({__name__=~".+"}))
```

Then inspect label values on the top metric. If a label is unbounded, choose the least destructive fix:

| Pattern | Safer fix |
|---|---|
| Raw paths like `/users/123/orders/456` | Rewrite to `/users/:id/orders/:id` |
| User, request, or session IDs | Remove the label from metrics; keep it in logs or traces |
| Debug-only metrics | Drop the metric in production |
| Histograms with unused buckets | Reduce buckets in instrumentation or drop unused `le` values |
| Kubernetes pod churn | Aggregate by workload, namespace, service, or cluster |

Prometheus metric relabeling can drop or rewrite labels before storage. Last9 can also reduce the blast radius at ingest: [Drop](/docs/control-plane-drop/) removes telemetry before storage, and [Streaming Aggregation](/docs/streaming-aggregations/) rolls high-cardinality metrics up before they hit long-term storage.

Use that carefully. Dropped data is gone. Aggregated data answers a coarser question. Keep the dimensions that explain incidents and remove the ones that only multiply cost.

## If queries are the driver: precompute the expensive work

Slow PromQL is a cost signal. It means Prometheus is scanning too much data, calculating the same expression too often, or asking one instance to answer a query that belongs in a precomputed series.

Turn on the query log in `prometheus.yml` to find repeated expensive queries:

```yaml
global:
  query_log_file: /var/log/prometheus/query.log
```

Prometheus picks this up on a config reload. Each line records the query, its timings, and where it came from.

Then move repeated dashboard and alert expressions into [Prometheus recording rules](https://last9.io/blog/prometheus-recording-rules/). The official [recording rules docs](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) describe the rule format; the practical point is that you compute a heavy expression once per interval and query the result many times.

```yaml
groups:
  - name: service_latency
    interval: 30s
    rules:
      - record: service:http_request_duration_seconds:p95_5m
        expr: |
          histogram_quantile(
            0.95,
            sum by (le, service) (rate(http_request_duration_seconds_bucket[5m]))
          )
```

Recording rules reduce query CPU and dashboard latency. They do not erase the raw series cost because Prometheus stores the input data first and the recorded output as another series. If the root problem is cardinality at ingest, recording rules are a query fix, not a storage fix.

Also check dashboard behavior. A dashboard with many panels refreshing every few seconds can produce meaningful query load even if each query looks reasonable alone. Increase refresh intervals for non-incident dashboards and shorten range windows where the longer window does not change the decision.

## If HA and global view are the driver: count every duplicate component

HA is not optional for production monitoring. The cost mistake is treating HA as one line item instead of a set of multipliers.

Count each part:

- Prometheus replicas scraping the same targets.
- Remote write streams from each replica.
- Object storage for long-term blocks.
- Query components and store gateways.
- Federation tiers and cross-region network traffic.
- Dashboards and alerts that query multiple backends.
- The operational work to upgrade, debug, and secure each component.

[Federation](https://prometheus.io/docs/prometheus/latest/federation/) can help when you need aggregated views across Prometheus servers, but it is not free. You maintain match rules, scrape another Prometheus layer, and decide which detail is safe to aggregate away.

Thanos and Cortex can extend Prometheus for long-term storage and global querying. They also add components, configuration, and ownership. Name that tradeoff in your cost review instead of treating the stack as still "just Prometheus."

We have a public migration case study on [cutting monitoring cost and replacing a self-hosted Thanos stack](https://last9.io/blog/how-we-reduced-monitoring-costs-and-deprecated-thanos-for-replit/). Whether or not you replace Thanos, count the time spent operating it as part of the HA and long-term storage cost.

## If remote write is the driver: reduce volume before tuning queues

Remote write cost shows up as network, backend ingestion, receiver capacity, and queue memory inside Prometheus. Before tuning shards, check whether the stream contains data you should not send.

Use `write_relabel_configs` when a metric should stay local but should not be shipped to remote storage:

```yaml
remote_write:
  - url: https://example-remote-write/api/v1/write
    write_relabel_configs:
      - source_labels: [__name__]
        regex: "debug_.*"
        action: drop
```

Then tune the queue. The official [remote write tuning docs](https://prometheus.io/docs/practices/remote_write/) call out the memory relationship:

```text
shard memory is proportional to shards × (capacity + max_samples_per_send)
```

That means increasing `capacity` and `max_samples_per_send` while leaving `max_shards` high can raise memory pressure. Our guide to [scaling Prometheus remote write](https://last9.io/blog/how-to-scale-prometheus-remote-write/) walks through reducing parallelism while preserving throughput.

If you do not need local querying on that Prometheus node, Prometheus Agent mode can scrape and remote write without the full local TSDB. Last9's [Prometheus integration docs](/docs/integrations/observability/prometheus/) show how to send Prometheus remote write data to Last9 and how to run Prometheus in agent mode.

## What to do when optimization is not enough

Optimization has a ceiling. You can reduce noisy metrics, tune retention, precompute expensive PromQL, and right-size HA. At some point, the remaining cost is the cost of the requirement: long retention, high cardinality, global queries, or less platform toil.

That is when the decision changes from "how do I tune Prometheus?" to "which part of the Prometheus architecture should I keep operating myself?"

Good reasons to move part of the workload to a backend:

- You need long-term retention beyond what local Prometheus should own.
- You run many Prometheus instances and need global queries.
- Cardinality is valid for debugging, but expensive for one Prometheus instance.
- Remote write and query layers are taking more operator time than the services they monitor.
- You need teams to keep PromQL and Grafana workflows without running the storage layer themselves.

Bad reasons:

- You have not measured the driver.
- You want to hide unbounded labels instead of fixing instrumentation.
- You expect a backend to make every metric free.

Keep Prometheus where it is strong: scraping, local alerting, short-window debugging, and PromQL workflows. Move the parts that have become storage, scale, or operations problems.

## Where Last9 fits

Last9 accepts Prometheus remote write data, so you can keep your existing Prometheus instrumentation and PromQL workflows while moving long-term, high-cardinality storage out of local Prometheus. The [Prometheus integration docs](/docs/integrations/observability/prometheus/) show the `remote_write` configuration and Agent mode setup.

The Last9 Control Plane drops, remaps, redacts, forwards, and aggregates telemetry at ingest, before storage. It also previews every rule against live data before you save it. For Prometheus cost work, the most relevant controls are:

- [Cardinality Explorer](/docs/cardinality-explorer/) to see which metrics and labels drive cardinality.
- [Drop rules](/docs/control-plane-drop/) to discard unwanted telemetry before storage.
- [Streaming Aggregation](/docs/streaming-aggregations/) to roll up high-cardinality metrics before storage.

Last9 has no hard limit on cardinality; 20M series per metric per day by default, raised on request. Labels like `customer_id` or `tenant` can stay on the metric.

Last9 fits best when the cost comes from the operating model around Prometheus: long retention, high-cardinality data, global queries, and the work of keeping that stack healthy.

## A practical Prometheus cost checklist

Run this checklist before you buy more infrastructure or delete data:

1. **Top metrics by series count:** which metric names own the most series?
2. **Top labels by value count:** which labels are unbounded?
3. **Ingestion rate:** did samples per second change after a deploy or autoscaling event?
4. **Retention flags:** are you keeping high-resolution data longer than the incident workflow needs?
5. **Query log:** which dashboards and alerts repeat expensive expressions?
6. **HA inventory:** how many replicas, remote write streams, and storage copies exist?
7. **Remote write backlog:** is the sender, network, or receiver the bottleneck?
8. **Operational work:** how many incidents involve the monitoring stack itself?

A useful cost review ends with one of four actions: reduce data at scrape time, precompute repeated query work, move old data out of the hot path, or stop operating a component that no longer earns its overhead.

## FAQ

### Why is Prometheus getting expensive?

Prometheus gets expensive when active series, samples per second, retention, replicas, remote storage, and operator time compound. Start by measuring head series, ingestion rate, disk growth, query duration, and HA duplication before cutting data.

### How do I reduce Prometheus storage cost?

Reduce Prometheus storage cost by tuning retention time and retention size, widening scrape intervals for low-value metrics, dropping noisy metrics before storage, and keeping high-resolution data only where it supports alerts or incidents.

### Does high cardinality increase Prometheus cost?

Yes. Every unique label set creates a time series. More series increase memory, disk, query work, `remote_write` volume, and the chance that Prometheus needs sharding or external storage.

### Do recording rules reduce Prometheus cost?

Recording rules reduce query cost by precomputing repeated PromQL expressions, but they do not remove the original raw series from local storage. Use them for hot dashboards and alerts, then fix ingestion if cardinality is the larger driver.

### When should I move Prometheus data to a managed backend?

Consider a managed backend when Prometheus optimization no longer covers long-term retention, global queries, high-cardinality metrics, HA operations, or the engineering time needed to run Thanos, Cortex, federation, and storage safely.
