码迷,mamicode.com
首页 > 系统相关 > 详细

Prometheus 监控进程

时间:2018-12-25 15:57:51      阅读:903      评论:0      收藏:0      [点我收藏+]

标签:info   map   mysqld   重启   name   eth   network   编写   bsp   

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

  技术分享图片

 

Prometheus 监控进程

标签:info   map   mysqld   重启   name   eth   network   编写   bsp   

原文地址:https://www.cnblogs.com/bigberg/p/10174222.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!