Skip to main content
Running Prometheus directly from the terminal (for example, ./prometheus) launches it in the foreground. If you close that terminal, Prometheus stops. It also won’t start automatically after a reboot. To run Prometheus like any other long‑running service — in the background and enabled at boot — create a dedicated systemd unit and a system user that owns the Prometheus files. This guide walks through:
  • creating a system user and directories
  • installing the Prometheus binaries and configuration
  • creating a systemd unit file
  • starting and enabling the service

1. Create a Prometheus user

Create a system user that cannot log in interactively. This user will own and run the Prometheus process.
Using --no-create-home and /bin/false prevents shell login for the prometheus user. This is a security best practice for service accounts.

2. Create directories and set permissions

Create directories for configuration and time series storage, then assign ownership to the prometheus user and group.
Table: directory purposes After you copy files (next steps), make sure the directories and files are owned by the prometheus user:

3. Download and extract Prometheus

Download the Prometheus release and extract it.

4. Install binaries and copy supporting files

Copy the prometheus binary and the promtool CLI to /usr/local/bin, and copy consoles and config files into /etc/prometheus.
consoles and console_libraries provide optional local web UI templates. If you are not using these right away, copying them still ensures the web UI works later without additional steps.

5. Test running Prometheus as the prometheus user

You can test the exact command the systemd unit will run:
This runs Prometheus in the foreground (for testing). When satisfied, stop it with Ctrl+C and proceed to create the systemd service.

6. Create the systemd service unit

Create /etc/systemd/system/prometheus.service with the contents below. This unit ensures Prometheus starts after the network is available and runs under the prometheus user.
Explanation highlights:
  • Wants=network-online.target and After=network-online.target ensure the network is up before Prometheus starts.
  • User / Group set the service account; Type=simple is sufficient for Prometheus.
  • ExecStart is the full command to run Prometheus with the correct paths.
You can create the file with:
The image shows a dark-themed command line interface titled "Prometheus Installation systemd," with no visible content or commands displayed.

7. Reload systemd, start and enable Prometheus

After adding or changing unit files, reload systemd and start the service:
Check the status:
To ensure Prometheus starts automatically on boot:
If systemctl status prometheus reports failures, inspect the journal for details: sudo journalctl -u prometheus -b. Common issues include incorrect file paths, file ownership, or an invalid prometheus.yml.

8. Troubleshooting tips

  • Confirm prometheus binary location: which prometheus or ls -l /usr/local/bin/prometheus.
  • Confirm config file syntax: promtool check config /etc/prometheus/prometheus.yml.
  • Check logs: sudo journalctl -u prometheus -f to tail live logs.

References

Watch Video