Scraping Prometheus metrics from replicas

aaron7HOBBY

10 months ago

Hi,

I have services which expose Prometheus metrics. Prometheus client libraries expose metrics via HTTP endpoints which are then scraped by the Prometheus server.

If services have more than one replica, how can I configure the Prometheus server to scrape from each replica? Reading the documentation, it doesn't look like it's possible to target specific replicas.

Thank you,

Aaron

Solved

3 Replies

10 months ago

It's not possible to target a specific replica, Prometheus would need to be able to dynamically get it's clients from a AAAA DNS lookup, as doing a DNS lookup on a private domain for a service that has multiple replicas will return n amount of results, one answer for each replica.

Here's an example of what that looks like in practice -

https://utilities.up.railway.app/dns-lookup?value=hello-world.railway.internal&type=ip

The hello-word service has 5 replicas.


aaron7HOBBY

10 months ago

Perfect, thanks Brody!

For others, here's an example scrape config to do this:

- job_name: "hello-world"
  dns_sd_configs:
    - names:
        - "hello-world.railway.internal"
      type: "AAAA"
      port: 8080

10 months ago

Awesome, thank you for that followup, super helpful!


Status changed to Solved brody 11 months ago