当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
How to use DBA_ hist_ active_ sess_ History analysis database history performance problems
Unix期末考试总结--针对直系
Get DOM element location information by offset and client
Working principle and practice of browser
ansible模块之include_tasks:为什么加了tags后导入的任务没有执行?
PHP 无限极分类和树形
[Lombok quick start]
MySQL索引【数据结构+索引创建原则】
try --finally
TP5中的getField()方法变化,tp5获取单个字段值
Passerelle haute performance pour l'interconnexion entre VPC et IDC basée sur dpdk
Concurrent optimization request
tp5 报错variable type error: array解决方法
Kids and COVID: why young immune systems are still on top
阅读笔记:Secure Federated Matrix Factorization
Oracle Performance Analysis Tool: oswatcher
Typescript (lower)
New formdata() when importing files
阅读笔记:FedGNN: Federated Graph Neural Network for Privacy-Preserving Recommendation
【代码解析(7)】Communication-Efficient Learning of Deep Networks from Decentralized Data