How can we add extra label to Prometheus metrics?

Nipun Talukdar picture Nipun Talukdar · Dec 4, 2017 · Viewed 14.7k times · Source

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

Answer

 k0ste  picture k0ste · Dec 29, 2017
- job_name: 'your_job'                 
  honor_labels: true                         
  static_configs:                     
  - targets:                          
    - '127.0.0.1'          
    labels:                           
      cluster: 'stage'