Prometheus is an open-source monitoring system that allows you to collect and analyze various metrics from your applications and infrastructure. It is designed to be highly scalable and adaptable, making it an excellent choice for monitoring large-scale environments.
In this article, we will walk you through the steps to use Prometheus to monitor your CentOS 7 server.
Prerequisites
- A CentOS-7 machine with root access.
Install Prometheus
To install Prometheus on your CentOS 7 server follow our article How to install Prometheus using Docker on Centos 7.
Installing Node Exporter
-
Node Exporter is a Prometheus exporter that exposes system metrics in a format that Prometheus can understand. You need to install Node Exporter on your CentOS 7 server using the following commands.
# curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
# tar -xzf node_exporter-*.tar.gz
# sudo cp node_exporter-1.2.2.linux-amd64/node_exporter /usr/local/bin/ -
Create a service file for the node exporter.
# vi /etc/systemd/system/node_exporter.service
-
Add the following content to the file.
[Unit]
Description=Node Exporter
After=network.target
[Service]
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target - Reload and start the node exporter service.
# sudo systemctl daemon-reload
# sudo systemctl enable node_exporter.service
# sudo systemctl start node_exporter.service -
Once it starts, use a browser to view Node Exporter’s web interface, which is available at
http://your_server_ip:9100/metrics
. You should see a page with a lot of text. -
Visit
http://your_server_ip:9090/targets
To see added targets. -
Visit
http://your_server_ip:9090
You can click the graph and query any server metrics and click execute to show output. It will show the console output. -
Click on Graph to view.