I'm working on use case where I need to scrape metrics at different scrape intervals. For example, metric_one
needs to be scraped for every 1 hr and metric_two
is scraped for every 15s. Both of these metrics are from the same target. The solution that I have tried is following:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'job_two'
static_configs:
- targets:
- targets: ["engine:5001"]
metric_relabel_configs:
- source_labels: [ __name__ ]
regex: 'metric_one'
action: drop
- job_name: 'job_one'
scrape_interval: 3600s
static_configs:
- targets:
- targets: ["engine:5001"]
metric_relabel_configs:
- source_labels: [ __name__ ]
regex: 'metric_two'
action: drop
This Prometheus config tries to run two different scrape jobs on same host. job_one
only scrapes metric_one
and job_two
only scrapes metric_one
, but the Prometheus service discovery does not work properly with job_two
and heath-check status is shown unknown
and sometimes it doesn't appear at all when I run up
in Prometheus console.
Is there any other proper solution to this or am I doing something wrong in this solution?