Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Prometheus to use non-default port

I would like to install Prometheus on port 8080 instead of 9090 (its normal default). To this end I have edited /etc/systemd/system/prometheus.service to contain this line:

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

I.e., I am using option --web.listen-address to specifiy the non-default port.

However, when I start Prometheus (2.0 beta) with systemctl start prometheus I receive this error message:

parse external URL "": invalid external URL "http://<myhost>:8080\"/"

So how can I configure Prometheus such that I can reach its web UI at http://<myhost>:8080/ (instead of http://<myhost>:9090)?

like image 721
rookie09 Avatar asked Nov 21 '17 13:11

rookie09


People also ask

How do I configure Prometheus?

Prometheus is configured via command-line flags and a configuration file. While the command-line flags configure immutable system parameters (such as storage locations, amount of data to keep on disk and in memory, etc.), the configuration file defines everything related to scraping jobs and their instances, as well as which rule files to load.

What port does Prometheus use when querying targets?

Prometheus adds default http port to the Host header when querying targets. · Issue #2226 · prometheus/prometheus · GitHub .

What happens if Prometheus configuration is not well formed?

Configuration. If the new configuration is not well-formed, the changes will not be applied. A configuration reload is triggered by sending a SIGHUP to the Prometheus process or sending a HTTP POST request to the /-/reload endpoint (when the --web.enable-lifecycle flag is enabled). This will also reload any configured rule files.

Is Prometheus running on localhost or localhost?

By default, it is running on localhost. I don't see any such option in the prometheus configuration maybe you should expand your question (but I don't have an answer; I'm also struggling with making prometheus load from a specific path, not root). The prometheus documentation is quite bad


1 Answers

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
like image 104
rookie09 Avatar answered Oct 29 '22 15:10

rookie09