Skip to main content

Thanos

Thanos is a set of components that extend Prometheus capabilities for long-term storage, high availability, and global view of metrics.

Architecture

This container provides a production-ready Thanos setup with:

  • Thanos 0.40.1 latest stable release
  • Multi-component support (query, sidecar, store, compact, receive, query-frontend, rule)
  • Environment-driven configuration for all settings
  • S3 object store support for durable storage
  • Multi-tenancy support via Receiver

Quick Start

services:
thanos-query:
image: ghcr.io/supanadit/containers/thanos:0.40.1-r4
container_name: thanos-query
environment:
THANOS_COMPONENT: query
THANOS_HTTP_ADDRESS: ":10902"
THANOS_GRPC_ADDRESS: ":10901"
THANOS_QUERY_STORE_ADDRESSES: "thanos-store:10904"
ports:
- "10902:10902"
- "10901:10901"

Components

Thanos can run in multiple modes:

ComponentDescription
queryPrometheus query engine with deduplication
sidecarPrometheus sidecar for block upload
storeStore API for querying stored blocks
compactBlock compactor with retention
receiveReceiver for remote write (multi-tenant)
query-frontendQuery frontend with caching
ruleRecording rules and alerts

Environment Variables

Common Configuration

VariableDescriptionDefault
THANOS_COMPONENTComponent to runquery
THANOS_HTTP_ADDRESSHTTP listen address0.0.0.0:10902
THANOS_GRPC_ADDRESSgRPC listen address0.0.0.0:10901
THANOS_DATA_DIRData directory/opt/thanos/data

Query Configuration

VariableDescription
THANOS_QUERY_STORE_ADDRESSESComma-separated store addresses
THANOS_REPLICA_LABELReplica label for deduplication

Sidecar Configuration

VariableDescription
THANOS_SIDECAR_PROMETHEUS_URLPrometheus URL
THANOS_SIDECAR_SHIPPER_UPLOAD_COMPACTEDUpload compacted blocks

Store Configuration

VariableDescription
THANOS_STORE_INDEX_CACHE_CONFIGIndex cache configuration (YAML)
THANOS_STORE_CACHING_BUCKET_CONFIGCaching bucket configuration (YAML)

Query Frontend Configuration

VariableDescription
THANOS_QUERY_FRONTEND_DOWNSTREAM_URLDownstream query URL
THANOS_QUERY_RANGE_SPLIT_INTERVALRange query split interval
THANOS_QUERY_RANGE_MAX_RETRIESMaximum retries per request
THANOS_LABELS_SPLIT_INTERVALLabels split interval

Compact Configuration

VariableDescription
THANOS_COMPACT_DOWNSAMPLING_DISABLEDisable downsampling
THANOS_COMPACT_RETENTION_RAWRaw block retention
THANOS_COMPACT_RETENTION_5M5m downsampled block retention
THANOS_COMPACT_RETENTION_1H1h downsampled block retention
THANOS_COMPACT_CONSISTENCY_DELAYConsistency delay
THANOS_COMPACT_COMPACTION_CONCURRENCYCompaction concurrency

Receive Configuration

VariableDescription
THANOS_RECEIVE_REPLICATION_FACTORReplication factor
THANOS_RECEIVE_LOCAL_ENDPOINTLocal endpoint
THANOS_RECEIVE_HASHRING_FILEHashring file path

S3 Object Store Configuration

VariableDescription
THANOS_S3_BUCKETS3 bucket name
THANOS_S3_ENDPOINTS3 endpoint URL
THANOS_S3_ACCESS_KEYS3 access key
THANOS_S3_SECRET_KEYS3 secret key
THANOS_S3_INSECUREUse HTTP instead of HTTPS
THANOS_S3_SIGNATURE_V2Use AWS Signature V2
THANOS_S3_CA_FILECA certificate file
THANOS_S3_CERT_FILEClient certificate file
THANOS_S3_KEY_FILEClient key file
THANOS_S3_INSECURE_SKIP_VERIFYSkip TLS verification

Deployment Scenarios

ScenarioUse CaseDocumentation
Basic QueryQuery metrics from PrometheusQuery component
With PrometheusLong-term storagePrometheus + Thanos
Multi-tenantReceive remote writesReceiver configuration

Example: Full Stack with Prometheus

services:
prometheus:
image: ghcr.io/supanadit/containers/prometheus:3.8.1-r2
environment:
PROMETHEUS_ENABLE_WEB_LIFECYCLE: "true"
PROMETHEUS_STORAGE_TSDB_MIN_BLOCK_DURATION: "2h"
PROMETHEUS_STORAGE_TSDB_MAX_BLOCK_DURATION: "2h"
volumes:
- prometheus_data:/opt/prometheus/data
- ./prometheus.yml:/etc/prometheus/prometheus.yml

thanos-sidecar:
image: ghcr.io/supanadit/containers/thanos:0.40.1-r4
environment:
THANOS_COMPONENT: sidecar
THANOS_SIDECAR_PROMETHEUS_URL: "http://prometheus:9090"
THANOS_S3_BUCKET: "thanos"
THANOS_S3_ENDPOINT: "minio:9000"
THANOS_S3_ACCESS_KEY: "admin"
THANOS_S3_SECRET_KEY: "password"
THANOS_S3_INSECURE: "true"
volumes:
- prometheus_data:/opt/thanos/data

thanos-store:
image: ghcr.io/supanadit/containers/thanos:0.40.1-r4
environment:
THANOS_COMPONENT: store
THANOS_S3_BUCKET: "thanos"
THANOS_S3_ENDPOINT: "minio:9000"
THANOS_S3_ACCESS_KEY: "admin"
THANOS_S3_SECRET_KEY: "password"
THANOS_S3_INSECURE: "true"

thanos-query:
image: ghcr.io/supanadit/containers/thanos:0.40.1-r4
environment:
THANOS_COMPONENT: query
THANOS_QUERY_STORE_ADDRESSES: "thanos-store:10901,thanos-sidecar:10901"
ports:
- "10902:10902"

volumes:
prometheus_data:

Important Notes

Data Directory

Different components require different volume mounts:

  • Sidecar: Mount Prometheus data to /opt/thanos/data
  • Store: Use separate volume at /opt/thanos/data
  • Compact: Use separate volume at /opt/thanos/data
  • Receive: Use volume at /opt/thanos/data

S3 Compatibility

Tested compatible with:

  • MinIO
  • AWS S3
  • Google Cloud Storage
  • Azure Blob Storage (via custom endpoint)

Prometheus Web Lifecycle

When using Thanos sidecar, enable Prometheus web lifecycle for config reloading:

environment:
PROMETHEUS_ENABLE_WEB_LIFECYCLE: "true"

Next Steps