当前位置:网站首页>Implementation of multi tenant read and write in Prometheus cortex
Implementation of multi tenant read and write in Prometheus cortex
2022-04-23 07:04:00 【A sunny afternoon】
Cortex All components of the will be from each request header Of X-Scope-OrgID Get tenants from ID. The tenant here represents the owner of a set of data , It is to Cortex Write data , And have the query authority of the data . be-all Cortex Components will be unconditionally trusted X-Scope-OrgID Request , So if you want to protect Cortex Protection from malicious calls , You need to add a protective layer by yourself .
Note the tenants who query and write requests ID It has to be consistent , Otherwise, the required data cannot be queried .
Enable the multi tenant feature
By adding auth.enabled=true, Or the command line -auth.enabled=true Enable the multi tenant feature . for example :
./cortex -target=distributor -auth.enabled=true
If you want to disable multi tenancy , You need to pass parameters to all components auth.enabled=false, In this case, all requests X-Scope-OrgID Will be set to "fake".
Prometheus To configure
The first method is to directly remote_write Add in configuration header Information .
remote_write:
- url: http://<cortex>/prometheus/api/v1/push
headers:
X-Scope-OrgID: <org>
The second method is to use Cortex-Tenant, Add... Based on existing tag values header Information .
Cortex Tenant Placed in Prometheus and Cortex Between , When Prometheus When a write request for passes through the component ,Cortex Tenant Will search for the value of the predefined tag , And use it as X-Scope-OrgID Add the value of to the request header in , And then forwarded to Cortex.

See the detailed usage method :
This component is a third-party component , Not Cortex Team maintenance .
Query side configuration
at present Cortex There is no front-end query page for multi tenant , In the use of Grafana As a client query , Multi tenant query can be implemented according to the following scheme .( At present, it is only an idea , Not yet practiced and tested , The theory works )
Scheme 1 :
stay Grafana And Cortex Place a layer between Nginx Reverse proxy ,Nginx Add a configuration similar to the following :
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 The side passes different tenants Org To separate from each other , Configure different data sources , In this way, different tenants can only query their own data .
Option two :
stay Grafana When adding data sources to , To configure Custom HTTP Headers.

版权声明
本文为[A sunny afternoon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230600558709.html
边栏推荐
猜你喜欢
随机推荐
MySQL server standalone deployment manual
redis 实践笔记和源码分析
Prometheus的relabel_configs和metric_relabel_configs解释及用法示例
Ansible基本命令、角色、内置变量与tests判断
tensorflow下载
[OSS file upload quick start]
Oracle net service: listener and service name resolution method
Prometheus监控influxdb的方法及指标释义
[shell script exercise] batch add the newly added disks to the specified VG
qs.stringify 接口里把入参转为&连接的字符串(配合application/x-www-form-urlencoded请求头)
基於ECS搭建雲上博客(雲小寶碼上送祝福,免費抽iphone13任務詳解)
AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
实践使用PolarDB和ECS搭建门户网站
Binary sum of leetcode questions
js 格式化当前时间 日期推算
prometheus告警记录持久化(历史告警保存与统计)
Prometheus Thanos快速指南
SQL学习|集合运算
虚拟环境中使用jupyter notebook
virtio 与vhost_net介绍








