This page looks best with JavaScript enabled

Granafa Host Monitoring Configuration

 ·  ☕ 2 min read

1. Install node exporter

1
2
3
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
tar  xvfz node_exporter-1.3.1.linux-amd64.tar.gz
mv node_exporter-1.3.1.linux-amd64/node_exporter /usr/local/bin/

If you cannot reach GitHub, refer to: Several ways to access GitHub from mainland China .

2. Configure and start the exporter

  • Add a Systemd configuration
1
vim /etc/systemd/system/node_exporter.service

Add the following content:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=Node Exporter
After=network.target

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

[Install]
WantedBy=multi-user.target
  • Start the exporter
1
2
systemctl daemon-reload
systemctl start node_exporter
  • Enable it at boot
1
systemctl enable node_exporter
  • Check the metrics endpoint locally
1
2
3
4
5
6
7
8
9
curl localhost:9100/metric

<html>
			<head><title>Node Exporter</title></head>
			<body>
			<h1>Node Exporter</h1>
			<p><a href="/metrics">Metrics</a></p>
			</body>
			</html>

3. Prometheus configuration

  • Add a job

Since Prometheus is deployed on Kubernetes, we edit the ConfigMap directly here:

1
kubectl -n monitor edit cm prometheus-server

Under the scrape_configs field, add the following content:

1
2
3
4
5
6
scrape_configs:
  - job_name: dev
    static_configs:
      - targets: ["1.1.1.1:9100"]
        labels:
          instance: dev
  • Check the targets

At this point the endpoint’s status is Up, which means data is being reported successfully.

4. Grafana configuration

Here you first need to add a Prometheus data source, then import the Grafana dashboard, and you can see the panels. Reference: Building Kubernetes monitoring with Prometheus and Grafana .

Many people use 8919 for host monitoring, but I find the dashboard a bit complex; here I use 1860. The result is shown below:


WeChat Official Account
WRITTEN BY
WeChat Official Account