prometheus监控进程

process-exporter简介

项目地址: https://github.com/ncabatoff/process-exporter

grafana:  https://grafana.com/grafana/dashboards/4202 | https://grafana.com/grafana/dashboards/10317

process-exporter是主要针对进程进行监控

部署

下载

wget https://github.com/ncabatoff/process-exporter/releases/download/v0.7.5/process-exporter-0.7.5.linux-amd64.tar.gz

tar xf process-exporter-0.7.5.linux-amd64.tar.gz -C /opt/process-exporter-0.7.5.linux-amd64

ln -s /opt/process-exporter-0.7.5.linux-amd64 /opt/process-exporter

准备监控模板

模板变量

 

  •  包含原始可执行文件的基本名称,即第二个字段 /proc/<pid>/stat

 [root@izx7dvghztbiorz process-exporter]# ps -ef | grep redis 
redis 771 1 0 Jun05 ? 00:45:49 /usr/bin/redis-server *:6379

{{.Comm}}  groupname="redis-server" exe或者sh文件名称
{{.ExeBase}} groupname="redis-server *:6379" /
{{.ExeFull}} groupname="/usr/bin/redis-server *:6379" ps中的进程完成信息
{{.Username}} groupname="redis" 使用进程所属的用户进行分组
{{.Matches}} groupname="map[:redis]"

表示配置到关键字“redis”

 

 

 

 

 

 

 

监控全部进程

process_names:
  - name: "{{.Comm}}"
    cmdline:
    - .+

监控指定进程

process_names:
  - name: "{{.Matches}}"
    cmdline:
    - nginx

  - name: "{{.Matches}}"
    cmdline:
    - zombie

准备启动文件

[root@ops targets]# cat /usr/lib/systemd/system/process-exporter.service 
[Unit]
Description=process-exporter Exporter
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/opt/process-exporter/process-exporter -config.path=/opt/process-exporter/process-exporter.yaml
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=process-exporter
[Install]

启动

systemctl start process-exporter.service 
systemctl enable process-exporter.service 
systemctl status process-exporter.service 

 

prometheus监控进程

上一篇:【Linux应用】进程时间


下一篇:数据完整性校验 - MD5, CRC, HMAC