关于thanos的介绍可以参考这篇官方博客的翻译文档,本文不作部署操作介绍。下图是thanos的官方架构图,主要有5个组件:
通常thanos管理多集群时,除Sidecar组件需要在每个集群内部署,其余组件仅部署一份,用于处理多个集群的数据。需要注意的是,thanos的StoreAPI采用的是gRPC协议,只能走四层通信,像在openshift 3.11版本下无法通过router(ingress)暴露给集群外部的Query等组件。规避办法为采用nodePort方式暴露,但通常nodePort并不是一个很好的方式,因为它占用了主机的端口。
从使用上看,thanos使用上最主要的作用就是实现了数据的持久化以及历史数据的提取,其实现的StoreAPI也可以作为可移植的功能。
TIPS:
type: ALIYUNOSS config: endpoint: "" bucket: "" access_key_id: "" access_key_secret: ""
version: ‘3.1‘ volumes: grafana_data: {} minio_data: {} store_data: {} compactor_data: {} services: thanos-querier: image: ${thanos-image} extra_hosts: - "${oss_backend}:${oss_backend_ip}}" command: - ‘query‘ - ‘--grpc-address=0.0.0.0:10901‘ # Query storeAPI - ‘--http-address=0.0.0.0:10902‘ # Query UI - ‘--query.replica-label=replica‘ - ‘--store=${prometheus_sidecar_lb}:${prometheus_sidecar_lb_port}‘ - ‘--store=thanos-store-gateway:${thanos-store-gateway_port}‘ privileged: true ports: - 10902:10902 restart: always thanos-store-gateway: image: ${thanos-image} extra_hosts: - "${oss_backend}:${oss_backend_ip}}" volumes: - ./thanos/:/etc/thanos/ - store_data:/data command: - ‘store‘ - ‘--grpc-address=0.0.0.0:10901‘ - ‘--http-address=0.0.0.0:10902‘ - ‘--data-dir=/data‘ - ‘--objstore.config-file=/etc/thanos/bucket_config.yaml‘ # Object store config file privileged: true restart: always thanos-compactor: image: ${thanos-image} extra_hosts: - "${oss_backend}:${oss_backend_ip}}" volumes: - ./thanos/:/etc/thanos/ - compactor_data:/data command: - ‘compact‘ - ‘--log.level=debug‘ - ‘--data-dir=/data‘ - ‘--objstore.config-file=/etc/thanos/bucket_config.yaml‘ - ‘--http-address=0.0.0.0:10902‘ - ‘--wait‘ privileged: true restart: always grafana: image: ${grafana-image} user: "104" ports: - 3000:3000 volumes: - grafana_data:/var/lib/grafana restart: always thanos-ruler: image: ${thanos-image} volumes: - ./thanos/:/etc/thanos/ command: - ‘rule‘ - ‘--grpc-address=0.0.0.0:10901‘ # Ruler Store API - ‘--http-address=0.0.0.0:10902‘ # Ruler UI - ‘--log.level=debug‘ - ‘--data-dir=/data‘ - ‘--eval-interval=15s‘ - ‘--query=thanos-querier:10902‘ - ‘--alertmanagers.url=http://alertmanager:9093‘ - ‘--rule-file=/etc/thanos/*.rules.yaml‘ - ‘--objstore.config-file=/etc/thanos/bucket_config.yaml‘ - "--label=monitor_cluster=\"poc-ocp01\"" - "--label=replica=\"r1\"" ports: - 10903:10902 privileged: true depends_on: - thanos-querier restart: always alertmanager: image: ${alertmanager-image} ports: - 10904:9093 volumes: - ./thanos/:/etc/alertmanager/ restart: always privileged: true command: - ‘--data.retention=120h‘ - ‘--web.listen-address=127.0.0.1:9093‘ - ‘--config.file=/etc/alertmanager/alertmanager.yaml‘ - ‘--storage.path=/alertmanager‘
原文:https://www.cnblogs.com/charlieroro/p/11612822.html