官方地址:https://github.com/ncabatoff/process-exporter
安装process
cd /opt/plg/tools
wget https://github.com/ncabatoff/process-exporter/releases/download/v0.5.0/process-exporter-0.5.0.linux-amd64.tar.gz
tar -xvf process-exporter-0.5.0.linux-amd64.tar.gz
mv process-exporter-0.5.0.linux-amd64 ../process-exporter
cd ../process-exporter/
编写配置文件
vim process-name.yaml
process_names:
#监控指定进程
- name: "{{.Matches}}"
cmdline:
- 'nginx'
- name: "{{.Matches}}"
cmdline:
- 'redis-server'
- name: "{{.Matches}}"
cmdline:
- 'mongod'
#监控所有进程
- name: "{{.Matches}}"
cmdline:
- '.+'
其中,name选项有四个(官方翻译https://github.com/ncabatoff/process-exporter):
{{.Comm}} 包含原始可执行文件的基本名称,即第二个字段 /proc//stat
{{.ExeBase}} 包含可执行文件的基名
{{.ExeFull}} 包含可执行文件的完全限定路径
{{.Username}} 包含有效用户的用户名
{{.Matches}} map包含应用cmdline regexps产生的所有匹配项
制作systemd 管理
cat >/usr/lib/systemd/system/process-exporter.service<<EOF
[Unit]
Description=node exporter
Documentation=node exporter
[Service]
ExecStart=/opt/plg/process-exporter/process-exporter -config.path /opt/plg/process-exporter/process-name.yaml
[Install]
WantedBy=multi-user.target
EOF
修改prometheus
vim prometheus.yml
scrape_configs:
#监控进程
- job_name: 'process'
static_configs:
- targets: ['192.168.11.161:9256']
#启动访问,重新加载prometheus
systemctl daemon-reload
systemctl start process-exporter.service
systemctl restart prometheus.service
添加模板
grafana 添加模版ID: 4202 | 249 | 8378 任选其一模版使用