Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically add targets to a Prometheus configuration

Tags:

prometheus

For a particular job in Prometheus, it seems like the typical config is something like this:

static_configs:
- targets: ['localhost:9090']

But in the case where I want a dynamic list of hosts, what would be the approach there? I was looking at scrape_config but that doesn't seem to accomplish what I'm after (unless I'm misreading?).

Thank you in advance!

like image 308
Thomas Stringer Avatar asked Oct 24 '17 17:10

Thomas Stringer


People also ask

How do you add targets in Prometheus?

Prometheus has a scraping configuration that allows you to add target you want to scrape. This is the documentation (a good starting point). Thanks for the answer. I actually fixed it mapping these configs by editing the configmap.

What is scrape config in Prometheus?

A scrape_config section specifies a set of targets and parameters describing how to scrape them. In the general case, one scrape configuration specifies a single job. In advanced configurations, this may change.


1 Answers

If one of the provided service discovery mechanisms doesn't already do what you need, you can use file_sd_configs to provide targets on the fly.

like image 138
brian-brazil Avatar answered Sep 29 '22 23:09

brian-brazil