Reputation: 834
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
)?
Upvotes: 18
Views: 54278
Reputation: 344
There is a default config location for prometheus & prometheus-node-exporter.
Both support --web.listen-address=host:port
in their respective config files in /etc/default/prometheus
and /etc/default/prometheus-node-exporter
It is noteworthy that prometheus & node-exporter will prefer to bind to an ipv6 (if ipv6 interface is present) using the default config value:
--web.listen-address=:9090
In that case, Prometheus will not bind to ipv4 interface and is only available with ipv6. Many people do not want this, and should set default listener interface explicitly.
These files in /etc/default/
are automatically read by the service units when starting up. It is not paradigmatic to modify the service unit, if there is a config file for the purpose.
Counterintuitively, it is not /etc/prometheus/prometheus.yml
, because this file only describes prometheus workloads not the system service configuration.
Upvotes: 2
Reputation: 179
I'm using Ubuntu 20.02. It requires:
--web.listen-address=:8080 #defaults to IPv6
--web.listen-address=*:8080 # does not work
--web.listen-address=192.168.1.X:8080 # for IPv4
Upvotes: 3
Reputation: 834
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
Upvotes: 29