Add custom params to prometheus scrape request

Viewed 3172

We have metrics endpoint enabled in our application to get metrics. It requires custom parameter, how to configure prometheus.yaml to send custom param as part of each metrics scrape

Below is my prometheus.yml configuration

# Sample METRICS    
- job_name: 'sys-metrics'
metrics_path: '/sys/metrics'
# Optional HTTP URL parameters.
params:
-user-id: ['myemail@email.com']
scrape_interval: 3s
static_configs:
- targets: ['dev.devhost.domain.com:12345']

When I start server, I get marshal error

parsing YAML file prometheus.yml: yaml: unmarshal errors:\n line 37: field -user-id not found in type config.plain"

Any help appreciated

1 Answers

under params, user-id is child element, add tab to resolve. as I defined at same level, prometheus expected to be one of pre-defined config.

params:
    -user-id: ['myemail@email.com']

Issue solved

Related