Tổng quan
Node Exporter là giải pháp VM, Host của Prometheus, sản phẩm được sử dụng để thu thập thông tin về hệ thống và tài nguyên tại máy chủ hoặc các thành phần trong mạng.
Node Exporter sẽ thu thập dữ liệu từ các máy chủ như thông tin CPU, bộ nhớ, dung lượng ổ đĩa, tình trạng mạng và nhiều thông số khác. Nó cung cấp các metric quan trọng để đo lường và theo dõi hiệu suất của hệ thống, từ đó giúp người dùng nhận biết các vấn đề tiềm ẩn và tối ưu hóa hoạt động của các máy chủ.
Với Node Exporter, người dùng có thể tạo ra các báo cáo và biểu đồ để theo dõi hiệu suất của hệ thống theo thời gian và phát hiện sự thay đổi và xu hướng. Nó cũng cung cấp thông cho cho việc cấu hình cảnh báo, cho phép người dùng đặt ngưỡng và nhận thông báo khi các metric vượt qua mức cảnh báo đã định trước.
Phần 1: Cài đặt Node Exporter
Chuẩn bị
- Thực hiện cài đặt dịch vụ Prometheus theo docs tại link
- Cài đặt Ubuntu version 20.04
- Cấu hình 2 CPU, 2 GB Ram, 50 GB Disk
- Trong bài, server của mình có IP 192.168.0.113
Bước 1: Tạo user cho node exporter
useradd --no-create-home --shell /bin/false node_exporterBước 2: Tải source code
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
tar xzf node_exporter-1.6.1.linux-amd64.tar.gz
sudo mv -v node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
node_exporter --versionIf your server is not amd, please check this link to choose the suitable version: https://sourceforge.net/projects/node-exporter.mirror/files/v1.6.1/
Bước 3: Tạo systemd
sudo vi /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --collector.systemd
[Install]
WantedBy=multi-user.targetBước 4: Khởi tạo dịch vụ
sudo systemctl daemon-reload
sudo systemctl start node_exporter.service
sudo systemctl enable node_exporter.service
sudo systemctl status node_exporter.service
Bước 5: Kiểm tra
http://192.168.0.113:9100/metrics

Phần 2: Cấu hình tại prometheus
Bước 1: Bổ sung thêm File cấu hình
Mở file
sudo vi /etc/prometheus/prometheus.ymlBổ sung
- job_name: 'client01'
scrape_interval: 5s
static_configs:
- targets: ['192.168.0.113:9100']File cấu hình tổng hiện tại
root@prometheus01:~# cat /etc/prometheus/prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'client01'
scrape_interval: 5s
static_configs:
- targets: ['192.168.0.113:9100']Bước 2: Khởi động lại prometheus
sudo systemctl restart prometheus.serviceBước 3: Kiểm tra
Truy cập graph, kiểm tra metrics
- http://192.168.0.113:9090/graph
- {instance=”192.168.0.113:9100″, job=”client01″}
Có metrics –> Cấu hình thành công

