安装thanos

下载:
https://github.com/thanos-io/thanos/releases/download/v0.22.0/thanos-0.22.0.linux-amd64.tar.gz

解压:
tar -xf thanos-0.22.0.linux-amd64.tar.gz -C /usr/local/

thanos 使用腾讯云cos

在主目录下创建一个yml的文件,配置对象存储的配置

  1. type: COS
  2. config:
  3. bucket: "thanos"
  4. region: "ap-nanjing"
  5. app_id: "1305787793"
  6. secret_key: "1nKfnlY7SZT8ZliSxGLBm8F6i5D8rVyC"
  7. secret_id: "AKIDxlMkyzlIbfU4QYQ3RaVFl24yf7PSGqER"
  8. http_config:
  9. idle_conn_timeout: 1m30s
  10. response_header_timeout: 2m
  11. tls_handshake_timeout: 10s
  12. expect_continue_timeout: 1s
  13. max_idle_conns: 100
  14. max_idle_conns_per_host: 100
  15. max_conns_per_host: 0

thanos 使用阿里云oos

  1. type: ALIYUNOSS
  2. config:
  3. endpoint: ""
  4. bucket: ""
  5. access_key_id: ""
  6. access_key_secret: ""

sidecar

  1. ./thanos sidecar --prometheus.url=http://127.0.0.1:9090 --tsdb.path=/prometheus-data --http-address 0.0.0.0:19191 --grpc-address 0.0.0.0:19090 --shipper.upload-compacted --objstore.config-file bucket.yml

store gateway

  1. nohup /usr/local/thanos/thanos store --data-dir /prometheus-data --objstore.config-file /usr/local/thanos/backet.yml --http-address 0.0.0.0:39191 --grpc-address 0.0.0.0:39090 > /usr/local/thanos/log/store.log 2>&1 &

—data-dir 数据目录 —objstore.config-file bucket配置 —http-address 监听地址与端口 —grpc-address api 访问地址与端口 —store 是sidecar和store的地址和端口

query

  1. nohup /usr/local/thanos/thanos query --http-address 0.0.0.0:19192 --store 10.111.22.16:19090 --store 10.111.22.17:19090 --store "10.111.22.18:39090" --store "10.111.22.20:39090" > /usr/local/thanos/log/query.log 2>&1 &

—store指定所有sidecar的访问地址和store的地址

以上几个组件均可分布式部署提高高可用
prometheus+sidecar 、store、query 可以按这几类区分

接下来就可以使用: curl $http-address:port 访问thanos页面