How can we add extra label to Prometheus metrics?

空扰寡人 提交于 2019-12-23 10:02:17

问题


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

Want to change that to:

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

回答1:


Unfortunately, it is not possible to change the labels on old metrics in Prometheus.

The storage is only updated by new scrapes and then it becomes immutable.




回答2:


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


来源:https://stackoverflow.com/questions/47628532/how-can-we-add-extra-label-to-prometheus-metrics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!