使用 Thanos 集中管理多 Prometheus 实例数据

1. 监控的分层

如上图,在建设监控系统时,会采用两种策略:

  • 分层监控。IaaS、MySQL 中间件、App 层监控分开的好处是,系统之间具有高可用性、容错性。当 App 层监控无法工作时,IaaS 层监控立马就会体现出来。
  • 长短期指标分离。短期指标用来提供给告警系统高频查询近期数据,长期指标用来提供给人查询时间跨度更大的数据集。
  • Prometheus 载入的不是降采样数据
  • Sidecar, 用于连接 Prometheus,提供 Query 查询接口、也可以上报数据
  • Store Gateway, 访问放在对象存储的指标数据
  • Compact, 压缩采样、清理对象存储中的数据
  • Receive, 接收 Prometheus Remote Write 的数据
  • Ruler, 配置和管理告警规则
  • Prometheus 无状态
  • 只需要暴露 Receiver 给 Prometheus 访问
  • 上传 Prometheus 的短期指标数据。默认每两个小时,创建一个块,上传到对象存储。
  • 需要 Store Gateway 能访问每个 Prometheus 实例
  • https://artifacthub.io/packages/helm/bitnami/thanos
  • https://github.com/shaowenchen/demo
  • https://imroc.cc/post/202004/build-cloud-native-large-scale-distributed-monitoring-system-3/