prometheus 是一个非常不多的metrics 监控解决方案,但是对于ha 以及多租户的处理并不是很好,当前有好多解决方案

  • cortex
  • Thanos
  • prometheus+ influxdb
  • Timebala
  • M3db
    以下结合github 上的一个docker-compose项目学习下Thanos 的集群方案

Thanos 参考架构图

简单说明

thanos 包含了sidecar,store api,query,compact 组件,sidecar 和每个promethues关联,同时配置prometheus 都配置了不同的label
以下是一个简单的组件通信图,可以参考https://improbable.io/games/blog/thanos-prometheus-at-scale 查看详细说明

docker-compose 运行

  • docker-compose文件
 
version: '3.7'
services:
  #
  # one prometheus and its sidecar
  #
  prometheus1:
    image: prom/prometheus:v2.9.2
    command:
    - --web.enable-lifecycle
    - --config.file=/etc/prometheus/prometheus.yml
    - --storage.tsdb.path=/prometheus
    - --web.console.libraries=/usr/share/prometheus/console_libraries
    - --web.console.templates=/usr/share/prometheus/consoles
    - --storage.tsdb.min-block-duration=1m # small just to not wait hours to test :)
    - --storage.tsdb.max-block-duration=1m # small just to not wait hours to test :)
    volumes:
    - ./prometheus1.yaml:/etc/prometheus/prometheus.yml
    - ./data1:/prometheus
    ports: 
    - "9090:9090"
    depends_on:
    - minio
  sidecar1:
    image: improbable/thanos:v0.4.0
    volumes:
    - ./data1:/var/prometheus
    - ./bucket_config.yaml:/bucket_config.yaml
    command:
    - sidecar
    - --tsdb.path=/var/prometheus
    - --prometheus.url=http://prometheus1:9090
    - --objstore.config-file=/bucket_config.yaml
    - --http-address=0.0.0.0:19191
    - --grpc-address=0.0.0.0:19090
    depends_on:
    - minio
  #
  # another prometheus and its sidecar
  #
  prometheus2:
    image: prom/prometheus:v2.9.2
    command:
    - --web.enable-lifecycle
    - --config.file=/etc/prometheus/prometheus.yml
    - --storage.tsdb.path=/prometheus
    - --web.console.libraries=/usr/share/prometheus/console_libraries
    - --web.console.templates=/usr/share/prometheus/consoles
    - --storage.tsdb.min-block-duration=1m # small just to not wait hours to test :)
    - --storage.tsdb.max-block-duration=1m # small just to not wait hours to test :)
    volumes:
    - ./prometheus2.yaml:/etc/prometheus/prometheus.yml
    - ./data2:/prometheus
    ports: 
    - "9091:9090"
    depends_on:
    - minio
  sidecar2:
    image: improbable/thanos:v0.4.0
    volumes:
    - ./data2:/var/prometheus
    - ./bucket_config.yaml:/bucket_config.yaml
    command:
    - sidecar
    - --tsdb.path=/var/prometheus
    - --prometheus.url=http://prometheus2:9090
    - --objstore.config-file=/bucket_config.yaml
    - --http-address=0.0.0.0:19191
    - --grpc-address=0.0.0.0:19090
    depends_on:
    - minio
  grafana:
    image: grafana/grafana
    ports:
    - "3000:3000"
  # to search on old metrics
  storer:
    image: improbable/thanos:v0.4.0
    volumes:
    - ./bucket_config.yaml:/bucket_config.yaml
    command:
    - store
    - --data-dir=/var/thanos/store
    - --objstore.config-file=bucket_config.yaml
    - --http-address=0.0.0.0:19191
    - --grpc-address=0.0.0.0:19090
    depends_on:
    - minio
  # downsample metrics on the bucket
  compactor:
    image: improbable/thanos:v0.4.0
    volumes:
    - ./bucket_config.yaml:/bucket_config.yaml
    command:
    - compact
    - --data-dir=/var/thanos/compact
    - --objstore.config-file=bucket_config.yaml
    - --http-address=0.0.0.0:19191
    - --wait
    depends_on:
    - minio
  # querier component which can be scaled
  querier:
    image: improbable/thanos:v0.4.0
    labels:
    - "traefik.enable=true"
    - "traefik.port=19192"
    - "traefik.frontend.rule=PathPrefix:/"
    command:
    - query
    - --http-address=0.0.0.0:19192
    - --store=sidecar1:19090
    - --store=sidecar2:19090
    - --store=storer:19090
    - --query.replica-label=replica
  #
  # s3 compatible storage
  #
  minio:
    image: minio/minio
    ports:
    - 9000:9000
    environment:
    - MINIO_ACCESS_KEY=minio
    - MINIO_SECRET_KEY=miniostorage
    volumes:
    - ./minio_data:/data
    command: server /data
  # a simple exporter to test some metrics
  domain_exporter:
    image: caarlos0/domain_exporter:v1
    ports: 
    - "9222:9222"
  # a load balancer to reverse-proxy to all queriers
  traefik:
    image: traefik
    restart: always
    ports:
      - 80:80
      - 8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik.toml:/traefik.toml
networks:
  default:
    driver: bridge
 
  • 简单说明
    通过traefik 提供统一的访问入口,每个prometheus 都关联一个thanos sidecar,启动包含了一个简单的domain_exporter 方便测试的
    每个prometheus 通过静态配置的方式,添加了服务的监控,对于对象存储使用了开源的minio,注意如果需要让store启动成功,需要
    进入minio创建对应的bucket

启动&&测试

  • 启动
docker-compose up -d
  • 创建minio bucket

为了保证store 启动成功,需要再运行下docker-compose up -d storer

  • 效果

统一入口(thanos 提供),界面如原生prometheus 基本一样,都是有差异,比如去重,还有就是status 中关于服务发现以及rule target 的配置没了
(因为thanos 统一处理了,不需要了)

原有prometheus 界面(可以通过9090,9091 查看)

grafana 界面

说明:
对于grafana prometheus 的配置,我们不使用以前的,直接使用thanos 提供的就可以了,配置如下:

minio 对象存储对于metrics 的存储(方便长时间的metrics 存储以及查询)

说明

以上是一个简单的docker-compose部署,从使用上对于thanos有一个简单的了解,学习简单的使用,更多的关于个组件的详细细节还需要查看
官方文档学习。

参考资料

https://github.com/mattbostock/timbala
https://github.com/cortexproject/cortex
https://github.com/thanos-io/thanos
https://github.com/influxdata/influxdb
https://github.com/m3db/m3
https://github.com/rongfengliang/thanos-playground

Thanos prometheus 集群以及多租户解决方案docker-compose 试用(一)的更多相关文章

  1. Prometheus集群介绍-1

    Prometheus监控介绍 公司做教育的,要迁移上云,所以需要我这边从零开始调研加后期维护Prometheus:近期看过二本方面的prometheus书籍,一本是深入浅出一般是实战方向的:官方文档主 ...

  2. 负载均衡集群中的session解决方案【转】

    通常面临的问题 从用户端来解释,就是当一个用户第一次访问被负载均衡代理到后端服务器A并登录后,服务器A上保留了用户的登录信息:当用户再次发送请求时, 根据负载均衡策略可能被代理到后端不同的服务器,例如 ...

  3. 【MySQL】MySQL-主从复制-集群方案-数据一致性问题解决方案 && MySQL备份的各种姿势

    1.写性能如何保证:分库分表 2.读性能如何保证:主从结构,实时备份 3.一致性问题怎么解决: 3.1.微博案例:Redis缓存,热数据查询走Redis,主从的延迟通过Redis消除 3.2.支付宝的 ...

  4. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之集群部署环境规划(一)

    0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.环境规划 软件 版本 ...

  5. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之部署master/node节点组件(四)

    0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 1.部署master组件 ...

  6. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录

    0.目录 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.感谢 在此感谢.net ...

  7. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之自签TLS证书及Etcd集群部署(二)

    0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.服务器设置 1.把每一 ...

  8. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之flanneld网络介绍及部署(三)

    0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.flanneld介绍 ...

  9. quartz集群分布式(并发)部署解决方案-Spring

    项目中使用分布式并发部署定时任务,多台跨JVM,按照常理逻辑每个JVM的定时任务会各自运行,这样就会存在问题,多台分布式JVM机器的应用服务同时干活,一个是加重服务负担,另外一个是存在严重的逻辑问题, ...

随机推荐

  1. k8s创建pod和service的过程

    一.概念介绍 更详细的参见:https://www.kubernetes.org.cn/5335.html 1.K8s K8s 是一种用于在一组主机上运行和协同容器化应用程序的系统,提供应用部署.规划 ...

  2. Windows ----tasklist/taskkill

    1) Tasklist命令详解 “Tasklist”命令是一个用来显示运行在本地或远程计算机上的所有进程的命令行工具,带有多个执行参数. 作用:结束一个或多个任务或进程.可以根据进程 ID 或图像名来 ...

  3. 核与线程 CPU 4核8线程 的解释

    1.物理CPU: 物理CPU就是计算机上实际配置的CPU个数.在linux上可以打开cat /proc/cpuinfo 来查看,其中的physical id就是每个物理CPU的ID,能找到几个phys ...

  4. winform+cefSharp实现窗体加载浏览器

    1:新建winform项目 2:安装cefSharp 3:配置管理器更改为X86 4:添加引用 using CefSharp; using CefSharp.WinForms; 5:项目启动,打开网页 ...

  5. C# 字符串和字节数组转换

    转自:http://blog.sina.com.cn/s/blog_683d60ff0100rhwk.html 定义string变量为str,内存流变量为ms,比特数组为bt 1.字符串转比特数组 ( ...

  6. CDN: trunk Repo update failed - CocoaPods

    解决方案: 1.podfile文件中添加source源:  source 'https://github.com/CocoaPods/Specs.git' 2.执行 pod repo remove t ...

  7. Vue学习之基础及部分指令小结(一)

    一.理解MVC和MVVM的关系: MVC:Model View Controller (模型 视图 控制器) 分别为:业务逻辑.界面.用来调度View和Model层 MVVM:Model View V ...

  8. 冬虫夏草winterwormsummerherb英语

    “中药之王”--冬虫夏草WinterwormSummerherb King of Chinese medicine --WinterwormSummerherb “冬天是虫,夏天是草,冬虫夏草是个宝. ...

  9. 面试题:什么叫2B树

    在B树的基础上,每个节点有两个域,且他们是有顺序的,在层次上的又满足二叉排序树的性质

  10. elasticsearch Terms Query 实现类似于sql in查询

    本文demo基于elasticsearch 5.1.1,  项目中使用的还是较早的版本 例如 import com.alibaba.fastjson.JSON; import org.elastics ...