In this guide, we will walk you through the steps to install Node Exporter, Prometheus, and Grafana on a Linux Debian system. These tools are essential for monitoring and visualizing system metrics.
Before starting, ensure you have the following:
Node Exporter is a tool that collects system metrics and makes them available for Prometheus to scrape.
Download Node Exporter: Open your terminal and run the following command to download the latest version of Node Exporter:
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
Extract the tarball: Extract the downloaded file using the following command:
tar xvfz node_exporter-1.3.1.linux-amd64.tar.gz
Move the binary to /usr/local/bin
:
Move the Node Exporter binary to a directory in your system's PATH:
sudo mv node_exporter-1.3.1.linux-amd64/node_exporter /usr/local/bin/
Create a systemd service file for Node Exporter: Create a systemd service file to manage Node Exporter as a service:
sudo nano /etc/systemd/system/node_exporter.service
Add the following content to the file:
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
Reload systemd and start Node Exporter: Reload the systemd daemon and start the Node Exporter service:
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
Verify that Node Exporter is running: Check if Node Exporter is running by accessing its metrics endpoint:
curl http://localhost:9100/metrics
Prometheus is a monitoring and alerting toolkit that collects and stores metrics.
Download Prometheus: Download the latest version of Prometheus using the following command:
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
Extract the tarball: Extract the downloaded file:
tar xvfz prometheus-2.30.3.linux-amd64.tar.gz
Move the binaries to /usr/local/bin
:
Move the Prometheus and Promtool binaries to a directory in your system's PATH:
sudo mv prometheus-2.30.3.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-2.30.3.linux-amd64/promtool /usr/local/bin/
Create a configuration directory and copy the config file: Create a directory for Prometheus configuration and copy the default configuration file:
sudo mkdir /etc/prometheus
sudo cp prometheus-2.30.3.linux-amd64/prometheus.yml /etc/prometheus/
Create a systemd service file for Prometheus: Create a systemd service file to manage Prometheus as a service:
sudo nano /etc/systemd/system/prometheus.service
Add the following content to the file:
[Unit]
Description=Prometheus
After=network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
Reload systemd and start Prometheus: Reload the systemd daemon and start the Prometheus service:
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus
Verify that Prometheus is running: Check if Prometheus is running by accessing its web interface:
curl http://localhost:9090
Grafana is a visualization tool that allows you to create dashboards for your metrics.
Add the Grafana repository: Add the Grafana repository to your system:
sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
Update the package list and install Grafana: Update your package list and install Grafana:
sudo apt-get update
sudo apt-get install grafana
Start and enable Grafana: Start the Grafana service and enable it to start on boot:
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
Verify that Grafana is running: Check if Grafana is running by accessing its web interface:
curl http://localhost:3000
Access Grafana:
Open your web browser and navigate to http://<your-server-ip>:3000
. Use the following default credentials to log in:
admin
admin
Configuration > Data Sources
.Add data source
.Prometheus
.http://localhost:9090
.Save & Test
.Dashboards > Manage
.Import
.1860
(Node Exporter Full) and click Load
.Import
.You have successfully installed Node Exporter, Prometheus, and Grafana on your Debian system. You can now monitor your system metrics and create beautiful dashboards to visualize them.
Happy monitoring!