Ubuntu – How to install the latest version of Prometheus on 16.04

16.04systemd

I'm having trouble installing the latest version of Prometheus on a fresh install of Ubuntu 16.04. All the guides that I can find are for 14.04 and the move from systemV to systemd makes these guides incompatible (or at least incomplete) when setting it up on 16.04.

I can install Prometheus from apt, but it installs version 0.16.2 and the current version is 1.0.2.

I've been using the official prometheus.io install guide and this guide on Digital Ocean.

Can anyone help me with the systemd setup? I'm relatively experienced with Ubuntu, but the systemd change is throwing me a curve ball.

Best Answer

The following unit file worked for me when installing the prometheus server version 1.x (as opposed to an exporter).

# /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=prometheus
Restart=on-failure
ExecStart=/usr/local/bin/prometheus-1.1.2.linux-amd64/prometheus \
                                -config.file=/etc/prometheus/prometheus.yml \
                                -storage.local.path=/var/lib/prometheus/data

[Install]
WantedBy=multi-user.target

This assumes, of course, that you've created a prometheus user and granted necessary permissions.

Then use the commands mentioned by WInfly.

$ sudo systemctl daemon-reload
$ sudo systemctl enable prometheus
$ sudo systemctl start prometheus
$ sudo systemctl status prometheus

I have found the following helpful:

Prometheus: https://blog.svedr.in/posts/prometheus-quick-start.html

Man pages for unit file directives: https://www.freedesktop.org/software/systemd/man/systemd.directives.html

Related Question