How to Install Prometheus on Ubuntu 24.04

How to Install Prometheus on Ubuntu 24.04
In order to install Prometheus on Ubuntu 24.04, you need to download the linux-amd64 tarball from Prometheus GitHub releases, unpack it, and run prometheus binary from within with --config.file pointing to your configuration. Below you can see how to do it, set up the proper systemd service and ensure the installation succeeded.
How do I download and install Prometheus on Ubuntu 24.04?
Download the linux-amd64 tarball from Prometheus GitHub releases, unpack it, and run prometheus binary from within with --config.file pointing to your configuration.
$ wget https://github.com/prometheus/prometheus/releases/download/v3.14.0/prometheus-3.14.0.linux-amd64.tar.gz
$ tar -xzf prometheus-3.14.0.linux-amd64.tar.gz
$ cd prometheus-3.14.0.linux-amd64/
$ ./prometheus --config.file=prometheus.yml
According to Prometheus installation page, this URL scheme is used for all of the precompiled Prometheus releases, where all you have to do for a new version is swap out the version number, not learn some other process.
Why should Prometheus run as its own dedicated user instead of root?
Creating a prometheus system user without login shell and without home directory limits the capabilities of a potential attack via Prometheus processes. It is a common precaution for any long-running network service and is not specific to Prometheus.
$ sudo useradd --no-create-home --shell /bin/false prometheus
The above command is the recommended step to perform before configuring Prometheus for systemd. Together --no-create-home and --shell /bin/false arguments define an account which is going to exist just to run Prometheus and not for any other purpose.
How do I run Prometheus as a systemd service?
Create a unit file at /etc/systemd/system/prometheus.service, which will run the binary as prometheus user and start the service with systemctl. This way, Prometheus will run on each system bootup instead of the current terminal only.
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable prometheus
$ sudo systemctl start prometheus
Above unit file structure is the recommended setup for running Prometheus. Wants=network-online.target and After=network-online.target arguments make sure Prometheus does not start scraping targets until the network is actually online.
How do I access the Prometheus web UI?
Visit http://localhost:9090. According to Prometheus official documentation, this is the status page describing itself, separate from the graphing and query interface, which is also available on this address.
http://localhost:9090
Prometheus's getting started guide explicitly says: "Prometheus should start up. You should also be able to browse to a status page about itself at localhost:9090" and after that redirects to the specific page localhost:9090/query.
How do I check whether Prometheus started correctly?
Run sudo systemctl status prometheus command and check sudo journalctl -u prometheus if something went wrong. Status command will tell you if the service is running; journal will tell you the reason of failure.
$ sudo systemctl status prometheus
$ sudo journalctl -u prometheus -b
Both of the above commands are taken from the same systemd setup guide. Status command will usually be enough in most cases but journal command will tell you the reason of a failed configuration or some permission issue if the service refuses to start.
Our VPS plans and Bare Metal servers provide systemd and network access, so running Prometheus as a systemd service will work precisely as described above.
Get started with Orbit Servers
Low-latency VPS, bare metal, and colocation across the US, EU, and APAC - provisioned instantly and built for performance-critical workloads.
Get startedRelated products
Written by
Julius