How to Configure a Specific Ip in Prometheus Yml Configuration File

How to configure a specific IP in prometheus yml configuration file?

You can use the command line option for configuring your listen address

./prometheus --web.listen-address="0.0.0.0:9090" 

How to config Prometheus to scrape all IPs behind a hostname in single period?

The configuration in the question appears correct for the task. However, in order to make it work, the DNS response must contain all target IPs at once. The way it works is like this:

  1. Prometheus makes a DNS request to obtain a list of targets.
  2. The list of targets gets cached for refresh_interval: 2s.
  3. Prometheus makes a scrape request for each target in the list.

At next iterations (defined by the scrape_interval) Prometheus may skip p.1 and p.2 if the the list of targets is not yet expired. The problem in the question is that DNS server returned only one IP and thus, Prometheus at each scrape_interval made only one scrape request. The randomly selected target received it's unique IP-based instance label and this is why the graph looks disconnected.

Configure Prometheus to use non-default port

The quotes were superfluous. This line will work:

ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus.yaml --web.enable-admin-api \
--web.listen-address=:8080

Unable to start prometheus even after using a different port

The target specification is not where to listen, it is where to collect metrics from.

What you want to modify is the listen address. The man page lists the command line option --web.listen-address="0.0.0.0:9090", you could either change the command line or modify the config file appropriately.

Oh, look here, someone has already answered a similar question with a better answer. The config file change suggested is:

# Set the command-line arguments to pass to the server.
ARGS="--web.listen-address=localhost:10090"

I did a google search for prometheus listen port config and found that answer. You should search before you ask, I should search before I answer.



Related Topics



Leave a reply



Submit