‍Prometheus is a powerful open-source monitoring and alerting platform that allows you to collect and analyze system metrics. In this guide, we will walk you through the step-by-step process of installing Prometheus and Node Exporter on your Debian 12 server. By the end of this tutorial, you will have a fully functional Prometheus setup and be able to monitor and analyze the performance of your Linux machines.

Prerequisites

Before we dive into the installation process, make sure you have the following:

  • A Debian 12 server
  • A non-root user with sudo privileges

Understanding Prometheus and Node Exporter

To get started, it’s important to understand the basic concepts behind Prometheus and Node Exporter. Prometheus collects data and metrics from target servers through HTTP endpoints and stores them as time series data. Each time series is identified by a metric name and key/value pairs.

Node Exporter is an exporter application that exposes hardware and kernel-related metrics from Linux machines to Prometheus. It comes as a single binary file that you can install on your target servers.

Installing Prometheus and Node Exporter

To install Prometheus and Node Exporter on your Debian 12 server, follow these steps:

  1. Update your Debian package index by running the following command:
sudo apt update
  1. Install Prometheus and Node Exporter using the APT package manager:
sudo apt install prometheus prometheus-node-exporter
  1. After the installation is complete, both Prometheus and Node Exporter will be running as systemd services. You can verify the status of the Prometheus service with the following command:
sudo systemctl status prometheus
  1. Similarly, you can check the status of the Node Exporter service:
sudo systemctl status prometheus-node-exporter

Configuring Prometheus

Once Prometheus and Node Exporter are installed, you need to configure Prometheus to start collecting metrics from your target servers. Follow these steps:

  1. Open the Prometheus configuration file using a text editor:
sudo nano /etc/prometheus/prometheus.yml
  1. Inside the scrape_configs section, add a new job named prometheus with the target endpoint as the IP address of your Prometheus server:
scrape_configs:
- job_name:"prometheus"
static_configs:
- targets:["192.168.10.15:9090"]
  1. Save the file and exit the text editor.
  2. Restart the Prometheus service to apply the changes:
sudo systemctl restart prometheus
  1. You can now access the Prometheus dashboard by visiting http://<your-server-ip>:9090 in your web browser. The dashboard provides a comprehensive view of the collected metrics and allows you to perform queries using PromQL, the Prometheus Query Language.

Adding Node Exporter to Prometheus

Next, let’s add Node Exporter to your Prometheus installation to start collecting metrics from your Linux machines. Follow these steps:

Checking Node Exporter Status

Before adding Node Exporter to Prometheus, ensure that Node Exporter is running correctly. Perform the following checks:

  1. Check the status of the Node Exporter service:
sudo systemctl status prometheus-node-exporter
  1. Verify that port 9100, which is used by Node Exporter, is in the LISTEN state:
ss -tulpn | grep 9100
  1. Access the Node Exporter metrics URL in your web browser:
http://<your-server-ip>:9100/metrics

Adding New Job to Prometheus

Once you have confirmed that Node Exporter is running, you can add it as a new job to Prometheus. Follow these steps:

  1. Open the Prometheus configuration file:
sudo nano /etc/prometheus/prometheus.yml
  1. Inside the scrape_configs section, add a new job named prometheus-node-exporter with the endpoint of the Node Exporter metrics:
scrape_configs:
- job_name:'prometheus-node-exporter'
scrape_interval: 5s
static_configs:
- targets:['192.168.10.15:9100']
  1. Save the file and exit the text editor.
  2. Restart the Prometheus service:
sudo systemctl restart prometheus
  1. Navigate to the Prometheus dashboard and click on the Status > Targets menu. You should see the Node Exporter listed as a target endpoint.

Basic Usage of the Prometheus Dashboard

Now that you have Prometheus and Node Exporter set up, let’s explore some basic usage of the Prometheus dashboard.

  1. Type the query node_os_info in the query box and click the Execute button. This query retrieves operating system details from Node Exporter.
  2. In the Console section, you will see detailed host information.
  3. Try another query, such as node_memory_Active_bytes, to check the active memory on the target server. In the Graph section, you will see the results visualized.
  4. You can also use PromQL to get specific data, such as node_memory_Active_bytes[5], which shows data for the last 5 minutes.

Conclusion

Congratulations! You have successfully installed Prometheus and Node Exporter on your Debian 12 server. You now have a powerful monitoring system in place to collect and analyze system metrics. With Prometheus, you can gain valuable insights into the performance of your Linux machines and make informed decisions to optimize your infrastructure.

To further enhance your monitoring setup, consider installing additional components like Alert Manager and Grafana. These tools can help you create automated alerts and visualize your metrics in real-time.

If you’re looking for reliable cloud hosting solutions, Shape.host offers Linux SSD VPS services that are scalable, efficient, and secure. Visit Shape.host to learn more about their hosting options and how they can empower your business with their cutting-edge technology.