当前位置:网站首页>Prometheus Cortex多租户读写的实现
Prometheus Cortex多租户读写的实现
2022-04-23 06:01:00 【洒满阳光的午后】
Cortex的所有组件会从每个请求header的X-Scope-OrgID中获取租户ID。此处的租户表示的是一组数据的拥有者,它向Cortex写入数据,并拥有该数据的查询权限。所有的Cortex组件都会无条件信任带X-Scope-OrgID的请求,因此如果希望保护Cortex免受恶意调用,需要自行添加一个保护层。
注意查询和写入请求的租户ID必须一致,否则无法查询到所需数据。
启用多租户特性
通过在配置文件中添加auth.enabled=true,或者命令行-auth.enabled=true启用多租户特性。例如:
./cortex -target=distributor -auth.enabled=true
如果希望禁用多租户,则需要向所有组件传递参数auth.enabled=false,这种情况下所有请求的X-Scope-OrgID都会被设置为"fake"。
Prometheus配置
方法一是直接在remote_write配置中添加header信息。
remote_write:
- url: http://<cortex>/prometheus/api/v1/push
headers:
X-Scope-OrgID: <org>
方法二是使用Cortex-Tenant,根据已有标签值添加header信息。
Cortex Tenant放置于Prometheus和Cortex之间,当Prometheus的写请求经过该组件时,Cortex Tenant会搜索其中的预定义标签的值,并将其作为X-Scope-OrgID的值添加到请求header中,再转发给Cortex。

详细使用方法见:
此组件为第三方组件,非Cortex团队维护。
查询侧配置
目前Cortex并没有提供多租户的前端查询页面,在使用Grafana作为查询客户端的情况下,可以按下面的方案实现多租户查询。(目前仅为构想,尚未实践和测试,理论可行)
方案一:
在Grafana与Cortex之间放置一层Nginx反向代理,Nginx添加类似如下配置:
server {
server_name prod.com
location / {
proxy_pass http://cortex;
proxy_set_header X-Scope-OrgID <prod tenant ID>;
}
}
server {
server_name ops.com
location / {
proxy_pass http://cortex;
proxy_set_header X-Scope-OrgID <ops tenant ID>;
}
}
Grafana侧将不同的租户通过Org隔离开,分别配置不同的数据源,以此实现不同租户仅能查询自身数据的目标。
方案二:
在Grafana中添加数据源的时候,配置Custom HTTP Headers。

版权声明
本文为[洒满阳光的午后]所创,转载请带上原文链接,感谢
https://zhangrongjie.blog.csdn.net/article/details/121407074
边栏推荐
- Sum (if) in MySQL_ Sum (if ()) in MySQL
- 关于 synchronized、ThreadLocal、线程池、Atomic 原子类的 JUC 面试题
- 阅读笔记:Meta Matrix Factorization for Federated Rating Predictions
- [MySQL basics] startup options and configuration files
- 【Shell脚本练习】将新加的磁盘批量添加到指定的VG中
- file_ get_ Two solutions to content accessing SSL errors
- Leak detection and vacancy filling (IX) -- Procedure
- rdma 介绍
- The time format is incorrect, and an error is reported when running the SQL file
- 2021-09-18
猜你喜欢
随机推荐
PHP background parsing after JQ serialization
Implementation of leetcode question brushing str ()
【代码解析(3)】Communication-Efficient Learning of Deep Networks from Decentralized Data
redis 常见问题
虚拟环境中使用jupyter notebook
Oracle Net Service:监听器与服务名解析方法
mysql中sum (if)_mysql 中sum (if())
Tensorflow&&Pytorch常见报错
AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
[Lombok quick start]
surprise库中evaluate函数弃用解决方法
Passerelle haute performance pour l'interconnexion entre VPC et IDC basée sur dpdk
Typescript (lower)
mysql密码过期的方法
leetcode刷题之x的算术平方根
百度地图坐标、Google坐标、腾讯坐标相互转化
offset和client獲取dom元素比特置信息
Each traversal usage of tp6
使用sed命令来高效处理文本
memcached 源码分析
![[Lombok quick start]](/img/30/92251e7e12ce6e1c3f1084caade4d3.png)








