Prometheus監控Linux和systemd服務


node_exporter采集Linux和systemd服務的配置方法:

常用指標:

•CPU

•內存

•硬盤

•網絡流量

•文件描述符

•系統負載

•系統服務數據接口:http://IP:9100

使用文檔:

https://prometheus.io/docs/guides/node-exporter/

GitHub:

https://github.com/prometheus/node_exporter

配置認證:

yum install httpd-tools -y

[root@k8s-2 node_exporter]# htpasswd -nBC 12 '' | tr -d ':\n'
New password:
Re-type new password:
$2y$12$.V3A0pS0zMMXfp3QOKOEL.x//efLDsyQ2yQRfh9PWw/FAHax5nm9W

[root@k8s-2 node_exporter]# pwd
/opt/monitor/node_exporter
[root@k8s-2 node_exporter]# cat config.yml
basic_auth_users:
 prometheus: $2y$12$.V3A0pS0zMMXfp3QOKOEL.x//efLDsyQ2yQRfh9PWw/FAHax5nm9W

普羅米修斯要拿到數據,需要增加配置(紅色部分):

scrape_configs:

-job_name: 'Linux Server'

basic_auth:

username: prometheus

password: 123456

static_configs:

-targets: ['192.168.121.132:9100']

檢查語法:

[root@k8s-1 prometheus]# ./promtool check config prometheus.yml
Checking prometheus.yml
SUCCESS: 0 rule files found

自啟動:

[root@k8s-2 node_exporter]# vim /usr/lib/systemd/system/node_exporter.service

[Unit]
Description=node_exporter

[Service]
ExecStart=/opt/monitor/node_exporter/node_exporter --web.config=/opt/monitor/node_exporter/config.yml --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

查看暴露的信息:

 131(監控端)和132(被監控端)都監控到了:

查看監控數據:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM