基于Docker Compose 部署thanos+Prometheus高可用

version: '2'
services:
  #####################################
  # prometheus 1 on host 1 
  #####################################
  prometheus:
    image: prom/prometheus:v2.45.0
    container_name: prometheus
    network_mode: host
    # ports:
    #   - "9090:9090"
    volumes:
      - /u01/prometheus:/prometheus
    command: 
      - --config.file=/prometheus/prometheus.yaml
      - --storage.tsdb.path=/prometheus/data
      - --storage.tsdb.retention.time=1d
      - --storage.tsdb.min-block-duration=2h
      - --storage.tsdb.max-block-duration=2h
      - --storage.tsdb.no-lockfile
      - --web.listen-address=0.0.0.0:9090
      - --web.read-timeout=1m
      - --web.enable-admin-api
      - --web.max-connections=10
      - --query.max-concurrency=20
      - --query.timeout=2m
      - --web.enable-lifecycle 
      - --log.level=info
      - --web.external-url=http://10.0.1.35:9090
    depends_on:
      - thanos_sidecar

      #  - --web.console.libraries=/usr/share/prometheus/console_libraries
      #  - --web.console.templates=/usr/share/prometheus/consoles

  #####################################
  # thanos sidecar 1  on host 1 
  #####################################
  thanos_sidecar:
    image: thanosio/thanos:v0.32.5
    container_name: thanos_sidecar
    network_mode: host
    user: nobody
    volumes:
      - /u01/prometheus:/prometheus
    environment:
      - REPLICA=A
    command:
      - sidecar
      - --log.level=debug
      - --tsdb.path=/prometheus/data
      - --prometheus.url=http://localhost:9090
      - --http-address=0.0.0.0:10902
      - --grpc-address=0.0.0.0:10901
      - --reloader.rule-dir=/prometheus/rules/
      - --reloader.config-file=/prometheus/prometheus.yaml.tmpl
      - --reloader.config-envsubst-file=/prometheus/prometheus.yaml
      #- --objstore.config-file=/prometheus/bucket_config.yaml
      - |
        --objstore.config=type: S3
        config:
          bucket: log-rules
          region: BEIJING
          endpoint: xx
          access_key: xx
          secret_key: xx
          insecure: true
          signature_version2: true


  #####################################
  # thanos store 1  on host 1 
  #####################################
  thanos_store:
    image: thanosio/thanos:v0.32.5
    container_name: thanos_store
    network_mode: host
    user: nobody
    volumes:
      - /u01/thanos_store:/data
    command:
      - store
      - --log.level=debug
      - --data-dir=/data
      - --index-cache-size=500MB
      - --chunk-pool-size=500MB
      - --http-address=0.0.0.0:10906
      - --grpc-address=0.0.0.0:10905
      - |
        --objstore.config=type: S3
        config:
          bucket: log-rules
          region: BEIJING
          endpoint: xx
          access_key: xx
          secret_key: xx
          insecure: true
          signature_version2: true
    depends_on:
      - prometheus


  #####################################
  # thanos compact 1  on host 1 
  #####################################
  thanos_compact:
    image: thanosio/thanos:v0.32.5
    container_name: thanos_compact
    network_mode: host
    user: nobody
    volumes:
      - /u01/thanos_compact:/data
    command:
      - compact
      - --log.level=debug
      - --data-dir=/data
      - --http-address=0.0.0.0:10907
      - --wait
      - |
        --objstore.config=type: S3
        config:
          bucket: log-rules
          region: BEIJING
          endpoint: xx
          access_key: xx
          secret_key: xx
          insecure: true
          signature_version2: true
    depends_on:
      - prometheus


  #####################################
  # thanos query 1  on host 1 
  #####################################     
  thanos_query:
    image: thanosio/thanos:v0.32.5
    container_name: thanos_query
    network_mode: host
    command:
      - query
      - --query.replica-label=replica
      - --http-address=0.0.0.0:10903
      - --grpc-address=0.0.0.0:10904
      - --store=10.0.1.35:10901
      - --store=10.0.1.36:10901
      - --store=10.0.1.35:10905
      - --store=10.0.1.36:10905


  #####################################
  # alertmanager 1  on host 1 
  #####################################
  alertmanager:
    image: prom/alertmanager:v0.25.0
    container_name: alertmanager
    network_mode: host
    volumes:
      - /u01/alertmanager:/alertmanager
    # ports:
    #   - "9093:9093"
    command:
      - --config.file=/alertmanager/alertmanager.yaml
      - --storage.path=/alertmanager
      - --web.external-url=http://10.0.1.35:9093
      - --cluster.listen-address=0.0.0.0:9094
      - --cluster.advertise-address=10.0.1.35:9094
      - --cluster.peer=10.0.1.36:9094
 

  #####################################
  # grafana  on host 1 
  #####################################
  grafana:
    image: grafana/grafana-oss:10.1.1-ubuntu
    container_name: grafana
    network_mode: host
    user: "0:0"
    # ports:
    #   - "3000:3000"
    # user: $(id -u)
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
      - GF_PATHS_CONFIG=/var/lib/grafana/conf/grafana.ini
      - GF_PATHS_PROVISIONING=/var/lib/grafana/conf/provisioning
      - GF_PATHS_DATA=/var/lib/grafana/data
      - GF_PATHS_PLUGINS=/var/lib/grafana/data/plugins
    volumes:
      - /u01/grafana:/var/lib/grafana
    depends_on:
      - prometheus


  ##########################################
  # prometheus dingtalk webhook  on host 1 
  ##########################################
  #dingtalk-webhook:
  #  image: timonwong/prometheus-webhook-dingtalk:v2.1.0
  #  container_name: dingtalk-webhook
  #  network_mode: host
    # ports:
    #   - "8060:8060"
  #  volumes:
  #    - /u01/dingtalk-webhook:/etc/prometheus-webhook-dingtalk
  #  command:
  #    - --web.listen-address=:8060
  #    - --web.enable-ui
  #    - --web.enable-lifecycle
  #    - --config.file=/etc/prometheus-webhook-dingtalk/config.yaml
  #    - --log.level=info

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值