当前位置:网站首页>Relabel of Prometheus_ Configs and metric_ relabel_ Configs explanation and usage examples
Relabel of Prometheus_ Configs and metric_ relabel_ Configs explanation and usage examples
2022-04-23 07:05:00 【A sunny afternoon】
Configuration definition
First look at the location of the two configurations :
global:
......
# A list of scrape configurations.
scrape_configs:
# The job name assigned to scraped metrics by default.
- job_name: <job_name>
........
# List of target relabel configurations.
relabel_configs:
[ - <relabel_config> ... ]
# List of metric relabel configurations.
metric_relabel_configs:
[ - <relabel_config> ... ]
<relabel_config> relabel_config | Prometheus
# The source labels select values from existing labels. Their content is concatenated
# using the configured separator and matched against the configured regular expression
# for the replace, keep, and drop actions.
[ source_labels: '[' <labelname> [, ...] ']' ]
# Separator placed between concatenated source label values.
[ separator: <string> | default = ; ]
# Label to which the resulting value is written in a replace action.
# It is mandatory for replace actions. Regex capture groups are available.
[ target_label: <labelname> ]
# Regular expression against which the extracted value is matched.
[ regex: <regex> | default = (.*) ]
# Modulus to take of the hash of the source label values.
[ modulus: <int> ]
# Replacement value against which a regex replace is performed if the
# regular expression matches. Regex capture groups are available.
[ replacement: <string> | default = $1 ]
# Action to perform based on regex matching.
[ action: <relabel_action> | default = replace ]
difference :relabel_configs Used to grab metrics Modified before target Existing labels for , Existing tags, that is, in the configuration source_labels Include ( Can be obtained from Prometheus UI Of target Page view )__address__、__meta_filepath、__metrics_path__、__scheme__、job as well as target Other labels added manually in .
metric_relabel_configs Used to modify the... Obtained after grabbing metric The label of , Usable source_labels Include instance、job already target Other labels added manually in .
Usage examples
Create a new label using an existing label
For example, add a... To the indicator IP label , Use the following configuration to achieve :
# relabel_config
- job_name: 'node'
file_sd_configs:
- refresh_interval: 1m
files:
- node_targets.yml
relabel_configs:
- source_labels: ['__address__']
regex: (.*):.*
target_label: 'IP'
Or use metric_relabel_configs, Note that the configuration is incorrect up Indicator effectiveness .
# metric_relabel_config
- job_name: 'node'
file_sd_configs:
- refresh_interval: 1m
files:
- node_targets.yml
metric_relabel_configs:
- source_labels: ['instance']
regex: (.*):.*
target_label: 'IP'
To a group job Add a new label to the indicator
For example, add a public tag env=“test”:
- job_name: 'node'
file_sd_configs:
- refresh_interval: 1m
files:
- config/node_targets.yml
relabel_configs:
- target_label: 'env'
replacement: 'test'
Use here relabel_configs perhaps metric_relabel_configs All possible , Because it doesn't involve source_labels The string is directly used instead of .
版权声明
本文为[A sunny afternoon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230600558514.html
边栏推荐
猜你喜欢
使用prom-label-proxy实现Prometheus Thanos的基于标签的多租户读
LeetCode刷题|368最大整除子集(动态规划)
[OSS file upload quick start]
Implementation of multi tenant read and write in Prometheus cortex
冬季实战营 动手实战-初识上云基础,动手实操ECS云服务器新手上路 领鼠标 云小宝 背包 无影
redis 常见问题
基於ECS搭建雲上博客(雲小寶碼上送祝福,免費抽iphone13任務詳解)
冬季实战营动手实战-上云必备环境准备,动手实操快速搭建LAMP环境 领鼠标 云小宝 背包 无影
MySQL 【读写锁+表锁+行锁+MVCC】
volatile 关键字的三大特点【数据可见性、指令禁止重排性、不保证操作原子性】
随机推荐
LeetCode刷题|38外观数组
BPF program of type XDP
Redis 详解(基础+数据类型+事务+持久化+发布订阅+主从复制+哨兵+缓存穿透、击穿、雪崩)
基於ECS搭建雲上博客(雲小寶碼上送祝福,免費抽iphone13任務詳解)
[no steps in a small step to a thousand miles] Oracle Application derivative ora-01455 error reporting processing
LeetCode刷题|两个链表的第一个公共节点
Oracle net service: listener and service name resolution method
Include of ansible module_ Tasks: why is the imported task not executed after adding tags?
Kids and COVID: why young immune systems are still on top
js 格式化当前时间 日期推算
异常记录-14
搭建基于OSS的图片分享网站-反馈有礼
用Future与CountDownLatch实现多线程执行多个异步任务,任务全部完成后返回结果
Prometheus Cortex使用Block存储时的相关问题
ubuntu下搭建mysql环境 & 初识SQL
JS function package foreach use return can not jump out of the outer function
EMR Based offline data analysis - polite feedback
JS realizes modal box dragging
js 函数包裹forEach中使用return跳不出外层函数
阿里云日志服务sls的典型应用场景