当前位置:网站首页>使用prom-label-proxy实现Prometheus Thanos的基于标签的多租户读
使用prom-label-proxy实现Prometheus Thanos的基于标签的多租户读
2022-04-23 06:01:00 【洒满阳光的午后】
本文档的前提是已有一个安装好的Thanos集群。
组件安装
Go安装:
Download and install - go.dev (google.cn)
prom-label-proxy安装:
go env -w GOPROXY=https://goproxy.cn
go get github.com/prometheus-community/prom-label-proxy
# 使用go env命令查看GOPATH,编译好的可执行文件在GOPATH的bin目录下
cd ~/go/bin
./prom-label-proxy --help
Caddy安装
yum install yum-plugin-copr
yum copr enable @caddy/caddy
yum install caddy
组件配置
假设Prometheus拥有如下external_labels(使用已有标签区分租户或者单独添加租户tenant标签均可):
# 租户OrgA prometheus.yml
global:
external_labels:
region: eu-west
tenant="OrgA"
replica: 0
# 租户OrgB prometheus.yml
global:
external_labels:
region: eu-east
tenant="OrgB"
replica: 0
启动prom-label-proxy:
nohup ./prom-label-proxy -label tenant -upstream http://<thanos_query_ip>:<thanos_query_port> -insecure-listen-address 0.0.0.0:8080 &
label参数的含义为所有发送给后端thanos query的请求url必须携带tenant=abc参数,否则会报错。
配置并启动caddy:
# vi /etc/caddy/Caddyfile
:8081 {
rewrite * ?{query}&tenant=OrgA
reverse_proxy localhost:8080
}
:8082 {
rewrite * ?{query}&tenant=OrgB
reverse_proxy localhost:8080
}
# 启动caddy
systemctl start caddy
其中8081端口提供给租户OrgA,8082端口提供给租户OrgB,即可保证每个租户只能查询到自身数据。
Grafana配置:
为Grafana中不同的Org添加各自的数据源(填写caddy地址)即可。
读路径结构

版权声明
本文为[洒满阳光的午后]所创,转载请带上原文链接,感谢
https://zhangrongjie.blog.csdn.net/article/details/121491696
边栏推荐
- 用Future与CountDownLatch实现多线程执行多个异步任务,任务全部完成后返回结果
- 异常记录-20
- 【代码解析(3)】Communication-Efficient Learning of Deep Networks from Decentralized Data
- ansible模块之include_tasks:为什么加了tags后导入的任务没有执行?
- 2021年国产数据库12强介绍
- JS performance optimization
- Number of stair climbing methods of leetcode
- fdfs启动
- 【不积跬步无以至千里】MySQL报大量unauthenticated user连接错误
- [step by step, even thousands of miles] MySQL reports a large number of unauthenticated user connection errors
猜你喜欢
随机推荐
[step by step, even thousands of miles] MySQL reports a large number of unauthenticated user connection errors
tc ebpf 实践
Jenkins搭建与使用
【MySQL基础篇】数据导出导入权限与local_infile参数
CentOS8搭建PHP8.0.3运行环境
Curry realization of function continuous call calculation and accumulation
openvswitch 编译安装
bcc安装和基本工具使用说明
【ES6快速入门】
你应该知道的 JVM 基础知识
Installing redis using a small leather panel in the window environment
压力测试工具 Jmeter
The arithmetic square root of X in leetcode
数据库基本概念:OLTP/OLAP/HTAP、RPO/RTO、MPP
PHP background parsing after JQ serialization
Will restarting the Oracle listener break the existing connection
用反射与注解获取两个不同对象间的属性值差异
Solution to page cache problem (use with caution)
postMan 传参总结
How to use DBA_ hist_ active_ sess_ History analysis database history performance problems






![[Lombok quick start]](/img/30/92251e7e12ce6e1c3f1084caade4d3.png)


