1.1 下载Process-exporter并安装
#下载Process_exporter
[root@prometheus src]# wget wget https://github.com/ncabatoff/process-exporter/releases/download/v0.5.0/process-exporter-0.5.0.linux-amd64.tar.gz
#解压并安装
[root@prometheus src]# tar xf process-exporter-0.5.0.linux-amd64.tar.gz
[root@prometheus src]# mv process-exporter-0.5.0.linux-amd64 ../
[root@prometheus local]# mv process-exporter-0.5.0.linux-amd64/ process-exporter
[root@prometheus local]# cat /etc/systemd/system/process-exporter.service
[Unit]
Description=node exporter
Documentation=node exporter
[Service]
ExecStart=/usr/local/process-exporter/process-exporter -config.path /usr/local/process-exporter/process-name.yaml
[Install]
WantedBy=multi-user.target
#3、配置文件匹配规则
配置文件根据变量名匹配到配置文件:
{{.Comm}} 包含原始可执行文件的basename,/proc//stat 中的换句话说,2nd 字段
{{.ExeBase}} 包含可执行文件的basename
{{.ExeFull}} 包含可执行文件的完全限定路径
{{.Matches}} 映射包含应用命令行tlb所产生的所有匹配项
#4、创建监控服务器进程配置文件
Process-exporter 可以进程名字匹配进程,获取进程信息。匹配规则由name对应的模板变量决定,以下表示监控进程名字为nginx(前提是我们已经安装了Nginx)
[root@prometheus local]# yum install epel* -y
[root@prometheus local]# yum install nginx -y
[root@prometheus local]# systemctl start nginx
#5、配置nginx进程监控配置文件
[root@prometheus process-exporter]# cat process-name.yaml
process_names:
- name: "{{.Matches}}"
cmdline:
- 'nginx'
#6、启动process-exporter
[root@prometheus process-exporter]# systemctl daemon-reload
[root@prometheus process-exporter]# systemctl enable process-exporter
[root@prometheus process-exporter]# systemctl start process-exporter
[root@prometheus process-exporter]# ss -lntp|grep process
LISTEN 0 128 :::9256 :::* users:(("process-exporte",pid=28543,fd=3))
#7、配置prometheus文件
[root@prometheus prometheus]# vim prometheus.yml
- job_name: 'process'
static_configs:
- targets: ['10.4.7.58:9256']
#8、重启prometheus服务
[root@prometheus prometheus]# systemctl restart prometheus
发现process-exporter起来了
1.2 配置grafana
填写ID:249
最后的出图结果。
1.3 监控所有进程
#配置yaml文件
[root@prometheus process-exporter]# cat process-name.yaml
process_names:
- name: "{{.Matches}}"
cmdline:
- '.+'
#重启客户端
[root@prometheus process-exporter]# systemctl restart process-exporter
最后结果: