Introduction

Prometheus is an open-source monitoring and alerting toolkit. Node Exporter is a Prometheus exporter that collects various metrics from a Linux/Unix system. This tutorial will guide you through the process of installing Prometheus and Node Exporter on Debian 12.

Prerequisites

Before you begin, ensure you have:

  1. A Debian 12 server or desktop system
  2. Sudo privileges or access to the root account

Step 1: Install Prometheus

Download the latest Prometheus release from the official website:

wget https://github.com/prometheus/prometheus/releases/download/v2.32.0/prometheus-2.32.0.linux-amd64.tar.gz

Extract the downloaded archive:

tar xvfz prometheus-2.32.0.linux-amd64.tar.gz

Move the extracted files to the appropriate directory:

sudo mv prometheus-2.32.0.linux-amd64 /opt/prometheus

Step 2: Configure Prometheus

Create a Prometheus configuration file:

sudo nano /opt/prometheus/prometheus.yml

Add the following configuration:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']

Step 3: Install Node Exporter

Download the latest Node Exporter release from the official website:

wget https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz

Extract the downloaded archive:

tar xvfz node_exporter-1.2.2.linux-amd64.tar.gz

Move the Node Exporter binary to the appropriate directory:

sudo mv node_exporter-1.2.2.linux-amd64/node_exporter /usr/local/bin/

Step 4: Configure Node Exporter as a Service

Create a systemd service file for Node Exporter:

sudo nano /etc/systemd/system/node_exporter.service

Add the following configuration:

[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

Reload systemd and start Node Exporter:

sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter

Step 5: Access Prometheus

Open a web browser and navigate to http://your_server_ip:9090 to access Prometheus. You can use Prometheus to monitor and query metrics.

Conclusion

Congratulations! You have successfully installed Prometheus and Node Exporter on Debian 12. You can now use Prometheus to monitor your system metrics and Node Exporter to collect metrics from your Debian system.

Was this answer helpful? 0 Users Found This Useful (0 Votes)