我们如何为 Prometheus 指标添加额外的标签? [英] How can we add extra label to Prometheus metrics?

查看:156
本文介绍了我们如何为 Prometheus 指标添加额外的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们要收集一个月的相同指标,现在我们想修改指标以添加额外的标签(在旧数据中也是如此),我们该怎么做.现有指标:

Suppose we are collecting the same metrics for one month and now we want to modify the metrics to have extra label (in the old data as well), how can we do that. Existing metric:

mongodb_exporter_last_scrape_duration_seconds{instance="127.0.0.1:9216",job="mongo"}

想要将其更改为:

mongodb_exporter_last_scrape_duration_seconds{cluster="stage", instance="127.0.0.1:9216",job="mongo"}   

推荐答案

- job_name: 'your_job'                 
  honor_labels: true                         
  static_configs:                     
  - targets:                          
    - '127.0.0.1'          
    labels:                           
      cluster: 'stage'

这篇关于我们如何为 Prometheus 指标添加额外的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆