Thanos docker-compose

From UVOO Tech Wiki
Revision as of 00:58, 23 June 2024 by Busk (talk | contribs) (Created page with "``` Running multiple Prometheus servers with Thanos and MinIO for object storage. This setup assumes you want to run two Prometheus instances, one MinIO instance for storage,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Running multiple Prometheus servers with Thanos and MinIO for object storage. This setup assumes you want to run two Prometheus instances, one MinIO instance for storage, and the necessary Thanos components.

Here's an example of a docker-compose.yml configuration:

yaml
Copy code
version: '3.8'

services:
  minio:
    image: minio/minio
    container_name: minio
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
    command: server /data
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - minio-data:/data

  prometheus1:
    image: prom/prometheus
    container_name: prometheus1
    volumes:
      - ./prometheus1.yml:/etc/prometheus/prometheus.yml
      - prometheus1-data:/prometheus
    ports:
      - "9090:9090"

  prometheus2:
    image: prom/prometheus
    container_name: prometheus2
    volumes:
      - ./prometheus2.yml:/etc/prometheus/prometheus.yml
      - prometheus2-data:/prometheus
    ports:
      - "9091:9090"

  thanos-store:
    image: thanosio/thanos:v0.24.0
    container_name: thanos-store
    command:
      - store
      - --objstore.config-file=/etc/thanos/minio.yml
      - --http-address=0.0.0.0:10902
    ports:
      - "10902:10902"
    volumes:
      - ./minio.yml:/etc/thanos/minio.yml

  thanos-sidecar-prometheus1:
    image: thanosio/thanos:v0.24.0
    container_name: thanos-sidecar-prometheus1
    command:
      - sidecar
      - --prometheus.url=http://prometheus1:9090
      - --tsdb.path=/prometheus
      - --objstore.config-file=/etc/thanos/minio.yml
    volumes:
      - prometheus1-data:/prometheus
      - ./minio.yml:/etc/thanos/minio.yml

  thanos-sidecar-prometheus2:
    image: thanosio/thanos:v0.24.0
    container_name: thanos-sidecar-prometheus2
    command:
      - sidecar
      - --prometheus.url=http://prometheus2:9090
      - --tsdb.path=/prometheus
      - --objstore.config-file=/etc/thanos/minio.yml
    volumes:
      - prometheus2-data:/prometheus
      - ./minio.yml:/etc/thanos/minio.yml

  thanos-querier:
    image: thanosio/thanos:v0.24.0
    container_name: thanos-querier
    command:
      - query
      - --http-address=0.0.0.0:10903
      - --store=thanos-store:10902
      - --store=thanos-sidecar-prometheus1:10901
      - --store=thanos-sidecar-prometheus2:10901
    ports:
      - "10903:10903"

volumes:
  minio-data:
  prometheus1-data:
  prometheus2-data:
You will also need a prometheus1.yml and prometheus2.yml configuration file for your Prometheus instances, as well as a minio.yml for the Thanos object storage configuration.

prometheus1.yml / prometheus2.yml
yaml
Copy code
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
minio.yml
yaml
Copy code
type: S3
config:
  bucket: "thanos"
  endpoint: "minio:9000"
  access_key: "minio"
  secret_key: "minio123"
  insecure: true
To get started, place the docker-compose.yml, prometheus1.yml, prometheus2.yml, and minio.yml files in the same directory, and then run:

bash
Copy code
docker-compose up -d
This will set up the environment with two Prometheus servers, MinIO for storage, Thanos Store, Thanos Sidecar for each Prometheus, and Thanos Querier for querying the data.