Thanos is an open-source, CNCF incubating project designed to scale out Prometheus setups.
While Prometheus is an industry favorite for scraping and alerting on time-series metrics, it has two major technical limitations when scaled to enterprise levels:
- Limited Storage Retention: Prometheus saves data to local disks. Keeping metrics for months or years requires massive, expensive solid-state storage.
- Lack of Global Querying: If you have 20 clusters running 20 isolated Prometheus instances, you cannot run a single dashboard query to view metrics across all of them simultaneously.
Thanos breaks through these barriers by converting Prometheus into a highly available, distributed monitoring system with virtually infinite long-term metric storage using low-cost cloud object storage (like AWS S3, Google Cloud Storage, or Azure Blob).
The Modular Architecture of Thanos
Thanos does not run as a single, monolithic background program. Instead, it follows a microservices architecture where separate components do one operational task well.
1. Thanos Sidecar
The Sidecar runs inside the exact same pod/server as your existing Prometheus instance.
- The Upload Engine: Every 2 hours, when Prometheus finishes baking its local metric files (TSDB blocks), the Sidecar grabs them and moves them to cloud object storage. This allows you to set a low disk retention on Prometheus (e.g., just 2 to 4 hours), keeping cluster disks small and inexpensive.
- The Real-Time Proxy: When a user queries for brand-new data, the Sidecar intercepts the request and pulls it straight out of Prometheus’s local, in-memory data.
2. Thanos Store Gateway
While the Sidecar handles new metrics, the Store Gateway manages historical data. It acts as a proxy sitting in front of your cloud storage bucket. It indexes the massive pool of historical metrics in your S3 bucket, making them searchable for user queries without crashing system memory.
3. Thanos Querier (Query Engine)
The Querier is the central engine of the system. It exposes a standard PromQL API endpoint, meaning you can point your Grafana dashboards directly to Thanos instead of Prometheus.
- Global View: When you request a metric graph, the Querier fans out the request to all connected Sidecars (for live data) and Store Gateways (for old data), stitching the answers together seamlessly.
- Deduplication: If you run two identical Prometheus instances side-by-side for High Availability (HA), they will scrape the exact same data points. The Thanos Querier automatically detects these duplicates on the fly and cleans them up into a single line on your dashboard.
4. Thanos Compactor
The Compactor runs as a background process over your cloud storage bucket to organize your metrics.
- Compaction: It merges small 2-hour metric chunks into larger daily files to reduce storage overhead.
- Downsampling: If you want to look at data from a year ago, you don’t need 15-second precision data points. The Compactor automatically downsamples historical code into 5-minute and 1-hour averages, speeding up long-term data queries from minutes to milliseconds.
Two Deployment Flavors: Sidecar vs. Receiver
Depending on how your organization secures its network boundaries, Thanos can be deployed in two different configurations:
| Approach | Architecture Style | Data Flow | Best For |
| Sidecar Pattern | Pull-Based | The central Thanos Querier pulls metrics out of remote cluster sidecars. | Environments with flat networks where clusters can safely talk to one another over a private connection. |
| Receiver Pattern | Push-Based | Remote Prometheus instances use remote_write to actively push metrics over HTTPS to a central Thanos Receiver endpoint. | Strict, multi-tenant network structures or edge locations where remote clusters cannot accept inbound traffic. |
Summary: The Business Value of Thanos
By adding Thanos on top of an enterprise monitoring stack like OpenShift or Kubernetes, operations teams achieve:
- Cost Reduction: Offloading old data from premium block storage (EBS/SAN) to low-cost object storage (S3) slashes monitoring bills.
- Infinite Retention: You can keep historical infrastructure metrics indefinitely to satisfy business compliance or audit reviews.
- Unified Panes of Glass: Dev teams can build high-level Grafana views that showcase metric trends across multiple worldwide clusters at the exact same time.