Skip to main content
Running Prometheus directly from the binary has two practical limitations:
  • It runs in the foreground, so closing your terminal stops the process.
  • It won’t start automatically after a system reboot.
This guide shows how to install Prometheus, place its files in standard system locations, and create a systemd service so Prometheus runs in the background, can be managed with systemctl, and starts automatically at boot.

Overview

High-level steps:
  1. Create a dedicated, non-login prometheus user.
  2. Create directories for configuration and TSDB storage.
  3. Download and extract Prometheus.
  4. Install binaries and CLI tools to /usr/local/bin.
  5. Copy consoles, libraries, and the config file into /etc/prometheus.
  6. Test a manual run as the prometheus user.
  7. Create a systemd unit file.
  8. Reload systemd, start, and enable the service.

1) Create a Prometheus user

Create a dedicated system user that cannot log in interactively:
Using a dedicated, non-login user reduces risk by limiting file access and attack surface for the Prometheus process.

2) Create directories for configuration and data

Create paths for Prometheus configuration and time-series data, then set ownership to the prometheus user and group:
These directories follow common Linux conventions: /etc for configuration and /var/lib for persistent service data.

3) Download and extract Prometheus

Download the Prometheus release tarball (example uses v2.37.0). Change the version string as required for newer releases:

4) Install binaries and CLI tools

Copy the Prometheus binary and the promtool utility into /usr/local/bin and set ownership and permissions:
Installing under /usr/local/bin keeps system-managed binaries separate from distribution packages.

5) Install console templates, libraries, and the config file

Copy the consoles and console_libraries directories plus your prometheus.yml into /etc/prometheus, then ensure the prometheus user owns them:
Note: consoles and console_libraries are used by the web-based Prometheus console (optional for basic scraping/storage).

6) Manual test run as the prometheus user

Before creating the systemd unit, verify Prometheus runs correctly as the prometheus user. This is the same command the systemd unit will use:
If the web UI is accessible on the default port (9090) and there are no errors, stop the process (Ctrl+C) and proceed to create the systemd unit.

7) Create a systemd unit file

Create the unit file at /etc/systemd/system/prometheus.service:
Paste the following content into the file:
What the unit sections mean: The unit ensures Prometheus starts after the network is up and runs with the least privileges.

8) Reload systemd, start, and enable Prometheus

After creating or changing a unit file, reload systemd and then start and enable the service:
Enable Prometheus at boot:
systemctl status should report the unit as active (running) and enabled.
If you update /etc/prometheus/prometheus.yml, reload the service to apply changes: sudo systemctl restart prometheus. For configuration checks, use promtool check config /etc/prometheus/prometheus.yml.

Troubleshooting tips

  • Verify permissions: ensure /etc/prometheus and /var/lib/prometheus are owned by prometheus:prometheus.
  • Check logs: sudo journalctl -u prometheus -f shows real-time unit logs.
  • Port conflicts: if 9090 is already used, change --web.listen-address in the unit or config to a different port.
You now have Prometheus installed and running under systemd, manageable with systemctl and configured to start automatically at boot.

Watch Video