问题
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