Configure scrape job with params: name based on fqdn / md5 / obfuscating function.

25 views
Skip to first unread message

Pedro Santos

unread,
Feb 19, 2020, 9:54:30 AM2/19/20
to Prometheus Users
Hi, I'm hitting some Netdata exporters and I need to identify the "name" of my prometheus server on the http requests that collects the metrics.

I need to make something of the form:

```
  - job_name:          'netdata'
    metrics_path:      '/api/v1/allmetrics'
    scheme:            'http'
    params:
    ....
      name:
      - prometheus_server_name_without_domain OR md5(fqdn)

    ...
```

where I need the prometheus server to resolve its fqdn and run a function on it.


Note that the same configuration file is deployed all servers in a farm of prometheus nodes (collectors), where metrics are being hashed and dropped/kept accordingly, hence the need for the server itself to know its name when parsing the job and being able to operate with it on the params section (as opposed to manually type in a static value for each server/configuration file).


Is this possible?
can a prometheus node identify an internal variable on de params declaration of a job; and use a fuction to obfuscate it ?

Thanks in advance

Brian Candler

unread,
Feb 19, 2020, 11:27:37 AM2/19/20
to Prometheus Users
> Hi, I'm hitting some Netdata exporters and I need to identify the "name" of my prometheus server on the http requests that collects the metrics.

The prometheus server can add extra labels as part of the scrape.  Some of the service discovery methods have the ability to add labels (e.g. file_sd can do this).  Otherwise you can use relabelling.

Pedro Santos

unread,
Mar 12, 2020, 6:54:40 AM3/12/20
to Prometheus Users
Hi Brian, thanks for your reply.

My issue is that the same config file is copied over to a farm of collectors, each of them hashing the config. (via scripting). Since I need to add a specific parameter to each prometheus node, so that netdata exporter knows it which prometheus is hitting it, I can not hard code neiter on the DNS record nor on the config file the param, as it needs to be unique to each prometheus doing the data collection job on the netdata endpoints.

Is there like a built-iin variable / code_convention, that can be used for this en on the configuration?
Reply all
Reply to author
Forward
0 new messages