Prometheus 普罗米修斯:基于其他标签添加标签
我已设置普罗米修斯使用sd文件: 这将在其他标签中添加任务arn作为标签:Prometheus 普罗米修斯:基于其他标签添加标签,prometheus,amazon-ecs,Prometheus,Amazon Ecs,我已设置普罗米修斯使用sd文件: 这将在其他标签中添加任务arn作为标签: container_label_com_amazonaws_ecs_task_arn= "arn:aws:ecs:us-west-1:xxxxxx:task/2c1655cd-36b7-4db9-4326-ee90537b6271" 在grafana中,我想使用任务ID(2c1655cd-36b7-4db9-4326-ee90537b6271在我的示例中)作为我的大多数统计数据的图例,可以从任务arn中提取。我可以添加
container_label_com_amazonaws_ecs_task_arn=
"arn:aws:ecs:us-west-1:xxxxxx:task/2c1655cd-36b7-4db9-4326-ee90537b6271"
在grafana中,我想使用任务ID(
2c1655cd-36b7-4db9-4326-ee90537b6271
在我的示例中)作为我的大多数统计数据的图例,可以从任务arn中提取。我可以添加一个新标签吗?这可以通过使用一个新标签来实现。这将允许您从源标签创建新的目标标签
scrape_configs:
- job_name: ecs
file_sd_configs:
- files:
- /prometheus/ecs_file_sd.yml
relabel_configs:
- source_labels: [container_label_com_amazonaws_ecs_task_arn]
regex: '.*\/(.*)'
replacement: '${1}'
target_label: task_id
上面将创建一个名为
task\u id
的新标签,其值位于容器标签\u com\u amazonaws\u ecs\u task\u arn
标签的//code>之后。虽然我认为它不能解决OP的问题,但我遇到了这个问题,因为这个标题与我一直坚持的标题类似
我有标签,例如:
label\u 1=“蓝色”
和label\u 2=“绿色”
我想添加一个新标签(label\u3
),使用label\u2
的值,并在label\u1
上匹配正则表达式
这可以通过使用带有多个源标签的relabel\u配置来实现
您能描述一下为什么使用relabel\u配置
而不是metric\u relabel\u配置
?我发现这篇博客文章将relabel
描述为pre-scrape,将metric
描述为post-scrape,pre-inspect。为什么这些名称如此不代表它们的实际用途?我们也可以使用类似的方法来为收集到的数据添加新的标签吗?比如添加env:“dev”作为标签?
scrape_configs:
- job_name: ecs
file_sd_configs:
- files:
- /prometheus/ecs_file_sd.yml
relabel_configs:
- source_labels: [container_label_com_amazonaws_ecs_task_arn]
regex: '.*\/(.*)'
replacement: '${1}'
target_label: task_id
- source_labels: [label_1, label_2]
separator: ';'
target_label: label_3
regex: "blue;(.+)"
replacement: '${2}'
action: replace