Prometheus 监控进程

Process-exporter

  process-exporter可以用来检测所选进程的存活状态

下载process-exporter

  下载地址:https://github.com/ncabatoff/process-exporter/releases/tag/v0.4.0  

安装部署process-exporter

tar -zxvf process-exporter-0.4.0.linux-amd64.tar.gz -C /usr/local/process-exporter

  编写配置文件

vim process-exporter-ncabatoff.yaml


process_names:

  - name: "{{.Matches}}"
    cmdline:
    - 'redis-server'

  - name: "{{.Matches}}"
    cmdline:
    - 'mysqld'

  - name: "{{.Matches}}"
    cmdline:
    - 'org.apache.zookeeper.server.quorum.QuorumPeerMain'

  - name: "{{.Matches}}"
    cmdline:
    - 'org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer'

  - name: "{{.Matches}}"
    cmdline:
    - 'org.apache.hadoop.hdfs.qjournal.server.JournalNode'

  注 cmdline:  所选进程的唯一标识,ps -ef 可以查询到。如果改进程不存在,则不会有该进程的数据采集到。

  编写启动脚本

vim /usr/lib/systemd/system/process_exporter.service

[Unit]
Description=Prometheus exporter for processors metrics, written in Go with pluggable metric collectors.
Documentation=https://github.com/ncabatoff/process-exporter
After=network.target

[Service]
Type=simple
User=prometheus
WorkingDirectory=/usr/local/process-exporter
ExecStart=/usr/local/process-exporter/process-exporter -config.path=/usr/local/process-exporter/process-exporter-ncabatoff.yaml
Restart=on-failure

[Install]
WantedBy=multi-user.target

  

启动process-exporter

systemctl daemon-reload
systemctl start process_exporter
systemctl enable process_exporter

  

验证

curl localhost:9256/metrics

  

修改Prometheus配置文件

增加

 - job_name: 'process'
    static_configs:
    - targets: ['172.16.8.187:9256']

  重启Prometheus

  

 

posted @ 2018-12-25 15:29  Bigberg  阅读(10326)  评论(1编辑  收藏  举报