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.
4 Answers
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=
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.targetThis 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 prometheusI have found the following helpful:
Prometheus:
Man pages for unit file directives:
1The server storage argument name changed in version 2.x, working syntax:
[Unit]
Description=Prometheus Server
After=network-online.target
[Service]
User=root
Restart=on-failure
ExecStart=/usr/local/bin/prometheus-2.2.1.linux-amd64/prometheus \ --config.file=/etc/prometheus/prometheus.yml \ --storage.tsdb.path=/var/lib/prometheus/data
[Install]
WantedBy=multi-user.target I found my answer in this article. The specific part that I was missing in trying to set this up to run with systemd was creating the unit file. Below is creating the unit file for node_exporter and then running it as a service. Hope this helps someone else!
Create the unit file:
$ sudo vim /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
[Service]
User=vxx
ExecStart=/home/vxx/Prometheus/node_exporter/node_exporter
[Install]
WantedBy=default.targetThen start the service after reloading daemon or reboot the server:
$ sudo systemctl daemon-reload
$ sudo systemctl enable node_exporter.service
$ sudo systemctl start node_exporter.service
$ sudo systemctl status node_exporter.service If anyone is still coming back to this question, I've scriptified the installation of prometheus, node_exporter, and apache_exporter based on this DigitalOcean Tutorial.
You can find my scripts here:
The following scripts may be of interest:
prometheus_install.bash
prometheus_node_exporter_install.bash
prometheus_apache_exporter_install.bashYou can download and run the scripts using the following:
wget
bash prometheus_install.bashNote that any existing prometheus configuration will be overridden.