Image from Wikimedia Commons

Running Prometheus with Systemd

Table of Contents

Prometheus is a powerful open-source monitoring system that can be used to collect and track a variety of metrics for your applications. In this guide, we will cover how to get Prometheus up and running with systemd on a Ubuntu or Debian server.

Download and Install Prometheus

Create a dedicated prometheus user with:

sudo useradd -M -U prometheus

Select a version for your system from here and download it:

tar -xzvf prometheus-2.40.0-rc.0.linux-amd64.tar.gz
sudo mv prometheus-2.40.0-rc.0.linux-amd64 /opt/prometheus

Change folder permissions for prometheus user with:

sudo chown prometheus:prometheus -R /opt/prometheus

Create Systemd Unit File

Create systemd service in /etc/systemd/system/prometheus.service with the following contents:

Description=Prometheus Server

ExecStart=/opt/prometheus/prometheus \
  --config.file=/opt/prometheus/prometheus.yml \
  --storage.tsdb.path=/opt/prometheus/data \


Start systemd service of Prometheus with:

sudo systemctl daemon-reload
sudo systemctl start prometheus.service

Enable service to start and system start-up:

sudo systemctl enable prometheus.service

Check the status of the service with:

sudo systemctl status prometheus.service

To view the logs of Prometheus for troubleshooting, type:

sudo journalctl -u prometheus.service -f