How to Install Prometheus on Debian Latest
Prometheus is an open-source monitoring system that collects and stores metrics information from various resources like servers, applications, and microservices. Installing Prometheus on Debian is a straightforward process that requires following a few simple steps.
In this tutorial, we will cover how to install Prometheus on Debian latest version.
Prerequisites
Before we begin, make sure your system meets the following prerequisites:
- A user account with sudo privileges
- Latest version of Debian installed on the system
- A stable internet connection
Step 1: Update the System
Update the installed packages and repositories on your Debian system by running the following command:
sudo apt-get update
Step 2: Install and Configure Prometheus
- Download the Prometheus package by running the following command:
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
- Extract the downloaded tarball using the following command:
tar xvf prometheus-2.30.3.linux-amd64.tar.gz
- Move the extracted directory to the /opt directory using the following command:
sudo mv prometheus-2.30.3.linux-amd64 /opt/prometheus
- Create a new user and group for Prometheus using the following command:
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
- Set the ownership of the Prometheus directory to the newly created user and group using the following command:
sudo chown -R prometheus:prometheus /opt/prometheus/
- Open a configuration file for Prometheus using the following command:
nano /opt/prometheus/prometheus.yml
- Add the following configuration to the file:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
Save and close the configuration file.
Create a systemd service file for Prometheus using the following command:
sudo nano /etc/systemd/system/prometheus.service
- Add the following configuration to the file:
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data
[Install]
WantedBy=multi-user.target
Save and close the file.
Reload the systemd daemon and start the Prometheus service using the following command:
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus
Step 3: Accessing the Prometheus UI
Prometheus UI can be accessed on the web browser by accessing the following URL:
http://<your-server-IP>:9090/
Congratulations! You have successfully installed Prometheus on your Debian system. You can now use Prometheus to collect, store and analyze metrics information from various sources.