1. The limits of Prometheus #
What Thanos solves.
Three needs #
| Need | Prometheus alone | With Thanos |
|---|---|---|
| Long retention | Local disk, a few weeks/months | Years, in cheap object storage |
| High availability | Two identical instances but two data sets | Deduplication at read time: a single view |
| Global view | One query = one server | One PromQL query across all clusters |
| Cost | SSD, grows with retention | Object storage + downsampling |
2. The components #
A modular toolbox.
Roles #
| Component | Role | Command |
|---|---|---|
| Sidecar | Runs next to Prometheus: exposes its data and uploads blocks | thanos sidecar |
| Query | Receives PromQL, queries the StoreAPIs, deduplicates | thanos query |
| Query Frontend | Splits and caches range queries | thanos query-frontend |
| Store Gateway | Serves historical blocks from object storage | thanos store |
| Compactor | Compacts, downsamples, applies retention | thanos compact |
| Ruler | Evaluates rules and alerts on the global view | thanos rule |
| Receive | Receives remote write (alternative to the sidecar) | thanos receive |
3. Sidecar or Receive? #
Two ways to feed Thanos.
Choosing your model #
| Criterion | Sidecar | Receive |
|---|---|---|
| Principle | Pull: Thanos reads the local Prometheus blocks | Push: Prometheus sends via remote write |
| Network | gRPC access to each Prometheus | A single entry point; isolated clusters |
| Latency of recent data | Direct via StoreAPI | After reception and replication |
| Multi-tenant | No | Yes (tenant header) |
| Complexity | Low | Higher (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)