Thanos prometheus 集群以及多租户解决方案docker-compose 试用(一)
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 试用(一)的更多相关文章
- Prometheus集群介绍-1
Prometheus监控介绍 公司做教育的,要迁移上云,所以需要我这边从零开始调研加后期维护Prometheus:近期看过二本方面的prometheus书籍,一本是深入浅出一般是实战方向的:官方文档主 ...
- 负载均衡集群中的session解决方案【转】
通常面临的问题 从用户端来解释,就是当一个用户第一次访问被负载均衡代理到后端服务器A并登录后,服务器A上保留了用户的登录信息:当用户再次发送请求时, 根据负载均衡策略可能被代理到后端不同的服务器,例如 ...
- 【MySQL】MySQL-主从复制-集群方案-数据一致性问题解决方案 && MySQL备份的各种姿势
1.写性能如何保证:分库分表 2.读性能如何保证:主从结构,实时备份 3.一致性问题怎么解决: 3.1.微博案例:Redis缓存,热数据查询走Redis,主从的延迟通过Redis消除 3.2.支付宝的 ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之集群部署环境规划(一)
0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.环境规划 软件 版本 ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之部署master/node节点组件(四)
0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 1.部署master组件 ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录
0.目录 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.感谢 在此感谢.net ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之自签TLS证书及Etcd集群部署(二)
0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.服务器设置 1.把每一 ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之flanneld网络介绍及部署(三)
0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.flanneld介绍 ...
- quartz集群分布式(并发)部署解决方案-Spring
项目中使用分布式并发部署定时任务,多台跨JVM,按照常理逻辑每个JVM的定时任务会各自运行,这样就会存在问题,多台分布式JVM机器的应用服务同时干活,一个是加重服务负担,另外一个是存在严重的逻辑问题, ...
随机推荐
- AGC035
Contest Page A 唯一会做的题/kk 题目相当于要求相邻三个的异或和为\(0\). 当我们放入了三个数\(a,b,c\)时,接下来的放入顺序显然一定是\(a,b,c,a,b,c,...\) ...
- AGC039
Contest Page A 对于一个长度为\(L\)的相同字符段,显然要花费\(\frac{L}{2}\)次操作才能使得相邻不相同.于是只需要分类讨论一下首尾字符是否相同,算出每种字符.每种长度的连 ...
- SQL系列(十二)—— insert update delete
前言 这个系列的前面都一直在介绍查询select.但是SQL中十分广泛,按对数据的不同处理可以分为: DML:全称Data Manipulation Language,从名字上可以看出,DML是对数据 ...
- 怎样调节Eclipse中的字体大小?
window->perference->appearance->colors and font->text font edit
- 创建和使用CI / CD管道【译】【原】
在GitLab 8.8中引入. 介绍 管道是持续集成,交付和部署的顶级组件. 管道包括: 定义要运行的作业的作业.例如,代码编译或测试运行. 定义何时以及如何运行的阶段.例如,该测试仅在代码编译后运行 ...
- 笔记:Java Language Specification - 章节17- 线程和锁
回答一个问题:多线程场景下,有时一个线程对shared variable的修改可能对另一个线程不可见.那么,何时一个线程对内存的修改才会对另一个线程可见呢? 基本的原则: 如果 读线程 和 写线程 不 ...
- MTSC2019-深圳站 议题征集
议题截止时间 11月初 议题投递地址 topic@testerhome.com 臣一路走来,没有敌人,看见的都是朋友和师长 —司马懿 关于中国移动互联网测试大会 MTSC 大会(中国移动互联网测试 ...
- js浏览器对象模型【BOM】(十三)
一.时间定时器1.超时调用setTimeout(fun,time) [返回一个唯一标识该超时调用的ID数值]参数:fun:要执行的函数time:设置第多少毫秒后执行fun函数 clearTime ...
- 49.react中使用less
1.安装less:npm install less less-loader --save 2.webpack.config.js中配置: oneOf: [ { test: /\.less$/, ...
- Shell 编程 case语句
本篇主要写一些shell脚本case语句的使用. 字符判断 #!/bin/bash read -p "请输入一个字符:" char case $char in [a-z]|[A-Z ...