Prometheus PromSQL 獲取系統服務運行狀態
使用systemd收集器:
--collector.systemd.unit-whitelist=".+" 從systemd中循環正則匹配單元
--collector.systemd.unit-whitelist="(docker|sshd|nginx).service" 白名單,收集目標
# 監控服務狀態 /usr/bin/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service
Node端修改啟動配置
1、修改啟動配置,添加參數:vim /usr/lib/systemd/system/node_exporter.service
[Unit] Description=https://prometheus.io [Service] Restart=on-failure ExecStart=/usr/local/node_exporter/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service [Install] WantedBy=multi-user.target
2、加載配置重啟服務
systemctl daemon-reload
systemctl restart node_exporter
監控端查看Node服務
1、通過promSQL查看服務
node_systemd_unit_state

2、查看docker服務運行幾個狀態
node_systemd_unit_state{instance="47.98.138.176:9100",job="node",name="docker.service"}

