Install Prometheus

Install Prometheus to collect and serve data

Prometheus

Prometheus handles data collection, storage, and queries. Data sources are configured as targets from which Prometheus will request metrics data. Prometheus stores this data and responds to Grafana queries against the data.

Create System Account

Create a system account under which Prometheus can run.

sudo adduser --system prometheus --group --no-create-home
Results of adduser command

Install Prometheus

The instructions below are for version 2.42.0. Check for newer versions of Prometheus, and adapt the instructions below.

Download the latest release.

Results of wget command

Unpack the release.

Results of tar command

Copy multiple executable files to /usr/local/bin.

Create additional required directories.

Change ownership on the /var/lib/prometheus directory so the prometheus service can access it.

Configure Startup

Create a systemd service file to configure automatic startup of the Prometheus service.

Insert the following into the Prometheus systemd service file.

Data retention is set to 32 days in the default configuration. The number of days can be increased by changing the value assigned to the storage.tsdb.retention.time flag in the last line of the ExecStart configuration above.

Save the file and exit the editor.

Optional: Clean Up Installation Files

Remove the Prometheus archive and installation directory.

Notes

Prometheus will listen on port 9090. This is the port for the Prometheus admin UI.

Last updated