Reputation: 462
I use the following config for Prometheus, and found no go_info
and go_gc_duration_seconds
metrics:
global:
scrape_interval: 60s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 3s
metric_relabel_configs:
- action: keep
source_labels:
- __name__
regex: go_info
- action: keep
source_labels:
- __name__
regex: go_gc_duration_seconds
static_configs:
- targets: ['localhost:9090']
when using the following config, I can found go_info
and go_gc_duration_seconds
metrics:
global:
scrape_interval: 60s
evaluation_interval: 15s
scrape_configs:
- job_name: 'ssli-prometheus'
scrape_interval: 3s
metric_relabel_configs:
- action: keep
source_labels:
- __name__
regex: go_info|go_gc_duration_seconds
static_configs:
- targets: ['localhost:9090']
if I want to keep a lot of metrics, I must add these metrics to regex
fields, like this:
metric_relabel_configs:
- action: keep
source_labels:
- __name__
regex: metrcis1|metrcis2|metrcis3|metrcis4......|metrcisN
I worried regex is too long, so can I config multiple keep
action to keep these metrics? like this:
metric_relabel_configs:
- action: keep
source_labels:
- __name__
regex: metrics1
- action: keep
source_labels:
- __name__
regex: metrics2
- action: keep
source_labels:
- __name__
regex: metrics3
...
- action: keep
source_labels:
- __name__
regex: metricsN
Upvotes: 1
Views: 1805
Reputation: 13456
Prometheus supports RE2 syntax.
You can simplify your config by using regex. The following expression selects all metrics that have a name starting with metrics
(ie. metrics1,metrics2,....,metricsN).
- action: keep
source_labels:
- __name__
regex: "metrics.*"
Upvotes: 1