Thanos: Long-Term Storage and Global Query for Prometheus

Thanos: Long-Term Storage and Global Query for Prometheus

Thanos exists because Prometheus deliberately does not solve long retention or global querying, and at some point you need both.

The three problems it solves

Retention. Prometheus stores data locally and is not designed to hold years of it. Thanos ships blocks to object storage, so retention becomes a bucket lifecycle policy rather than a disk size.

Global view. With several Prometheus servers, one per cluster or region, there is no single place to query across them. Thanos Query federates them behind one endpoint that speaks the Prometheus API, so Grafana points at one thing.

Deduplication. Running two identical Prometheus servers for availability means two copies of every series. Thanos deduplicates at query time, which is what makes HA pairs practical.

The components

  • Sidecar beside each Prometheus, uploading blocks and serving recent data
  • Store Gateway serving historical blocks from object storage
  • Query fanning out and deduplicating
  • Compactor downsampling and compacting blocks
  • Ruler evaluating recording and alerting rules globally

That is five components, and it is the honest cost. Thanos is not a drop-in: it is a distributed system you now operate alongside the one you had.

Thanos or Mimir

Mimir solves the same problems with a different shape: a single horizontally scalable service rather than components bolted beside existing Prometheus servers.

Thanos suits an estate that already has Prometheus servers you want to keep. Mimir suits building centralised metrics storage from the start. Neither is clearly better and the migration between them is real work.

Object storage

S3-compatible, so MinIO, Garage or SeaweedFS all work for self-hosting, as do cloud buckets.

Operational caution

Query fan-out can be expensive. A broad query across years of downsampled data in object storage will pull a great deal of it, and an unbounded dashboard query is how people discover their egress bill. Set query limits.

The Compactor must run as a single instance per bucket; two compactors on one bucket corrupt blocks.

License

Thanos is released under the Apache License 2.0.