RousselTMLEARNING

Observability

Thanos: extending Prometheus (high availability, global view and long retention)

Understand why and how to use Thanos: Prometheus limits, components (Sidecar, Query, Store Gateway, Compactor, Ruler, Receive), architecture and choosing a model.

1. The limits of Prometheus #

What Thanos solves.

Three needs #

Limits of a single Prometheus
Prometheus is excellent locally; Thanos makes it global and durable.
NeedPrometheus aloneWith Thanos
Long retentionLocal disk, a few weeks/monthsYears, in cheap object storage
High availabilityTwo identical instances but two data setsDeduplication at read time: a single view
Global viewOne query = one serverOne PromQL query across all clusters
CostSSD, grows with retentionObject storage + downsampling

2. The components #

A modular toolbox.

Roles #

Thanos architecture
Components are adopted one by one as needed.
ComponentRoleCommand
SidecarRuns next to Prometheus: exposes its data and uploads blocksthanos sidecar
QueryReceives PromQL, queries the StoreAPIs, deduplicatesthanos query
Query FrontendSplits and caches range queriesthanos query-frontend
Store GatewayServes historical blocks from object storagethanos store
CompactorCompacts, downsamples, applies retentionthanos compact
RulerEvaluates rules and alerts on the global viewthanos rule
ReceiveReceives remote write (alternative to the sidecar)thanos receive

3. Sidecar or Receive? #

Two ways to feed Thanos.

Choosing your model #

CriterionSidecarReceive
PrinciplePull: Thanos reads the local Prometheus blocksPush: Prometheus sends via remote write
NetworkgRPC access to each PrometheusA single entry point; isolated clusters
Latency of recent dataDirect via StoreAPIAfter reception and replication
Multi-tenantNoYes (tenant header)
ComplexityLowHigher (hashring, replication)
Good practice: Start with Sidecar + Query + Store + Compactor: it is the simplest, proven model, and it covers retention, HA and the global view.

A first look from the command line #

thanos --version
thanos --help                      # liste des sous-commandes
thanos sidecar --help | head -30
# Chaque composant expose /-/healthy, /-/ready et /metrics sur son port HTTP (10902 par défaut)

Related articles

Thanos Sidecar: attaching Thanos to Prometheus and uploading to object storage

Set up Thanos Sidecar: Prometheus settings (external labels, 2h blocks), objstore configuration, Docker Compo…

Thanos Query and Query Frontend: a global, deduplicated view

Configure Thanos Query: StoreAPI endpoints, deduplication by replica label, partial response, web interface, …

Thanos Store Gateway and Compactor: history, downsampling and retention

Serve history with the Store Gateway and optimize storage with the Compactor: compaction, 5m/1h downsampling,…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!