- Prometheus runs in the foreground, meaning that closing the terminal also terminates the process.
- It does not start automatically on boot, requiring manual intervention after each reboot.
Running Prometheus Manually
Initially, you might run Prometheus using:Creating a Dedicated Prometheus User
For security purposes, create a dedicated system user for running Prometheus. Since this account is not intended for interactive login, run the following command:Running Prometheus under its own user limits potential security breaches and improves overall system safety.
Setting Up Directories for Configuration and Data
Create the necessary directories for Prometheus configuration and data storage. The convention is to store configuration files in/etc and persistent data in /var/lib.
Downloading and Installing Prometheus
Before proceeding, download the Prometheus binary from the official release repository. For example:/usr/local/bin, which is the standard location for executables. Ensure these files are assigned to the Prometheus user for proper access control.
Configuring Prometheus Files
Next, copy the dashboard-related directories into the configuration directory. This includes the consoles and console libraries, which are essential for the Prometheus web interface:prometheus.yaml) to /etc/prometheus and rename it as prometheus.yml:
Running Prometheus with Custom Parameters
With the directories and configuration files in place, you can test the Prometheus binary with custom parameters. This command specifies the configuration file location, data storage path, and web console directories:Testing Prometheus with the proper parameters ensures that it can locate all necessary resources for a successful startup.
Creating a systemd Unit File for Prometheus
To integrate Prometheus with systemd, create a new unit file:- The [Unit] section ensures that Prometheus starts only after the network is online.
- In the [Service] section, Prometheus is assigned to run with the dedicated user and group, and the execution command is clearly defined.
- The [Install] section specifies that the service should be activated as part of the standard multi-user system startup.
Enabling and Starting the Prometheus Service
After saving the systemd unit file, reload systemd to register the new service:By following these steps, Prometheus will run as a managed background service and automatically start during system boot, ensuring continuous monitoring without manual intervention.