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