我们如何为Prometheus指标添加额外标签?

时间:2017-12-04 07:34:57

标签: prometheus prometheus-operator

假设我们收集相同的指标一个月,现在我们想要修改指标以获得额外的标签(在旧数据中),我们该怎么做。 现有指标:

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"}   

3 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:3)

不幸的是,无法更改Prometheus中旧指标的标签。

存储仅由新的擦除更新,然后变为不可变。

答案 2 :(得分:0)

如果你有服务发现配置,你也可以在 relabels_config 中添加标签

relabel_configs:
  - target_label: cluster
    replacement: stage
相关问题