prometheus+process_exporter进程监控

一、需要监控进程的服务器上配置
1、进入到临时工作目录,传入process_exporter包
[root@ Nginx1 ~]# cd work/
[root@ Nginx1 work]# rz
2、解压,并移动至/usr/local/目录下
[root@ Nginx1 work]# tar xzf process-exporter-0.7.5.linux-amd64.tar.gz
[root@ Nginx1 work]# mv process-exporter-0.7.5.linux-amd64 process-exporter-0.7.5
[root@ Nginx1 work]# mv process-exporter-0.7.5 /usr/local/
[root@ Nginx1 work]# cd /usr/local/
[root@ Nginx1 local]# ln -s process-exporter-0.7.5/ process-exporter
[root@ Nginx1 local]# cd process-exporter
3、写配置文件
[root@ Nginx1 process-exporter]# vi nginx.yaml

process_names:
  - name: "{{.Matches}}"
    cmdline:
- '/usr/local/nginx/sbin/nginx' (需监控的进程名字)

4、编写启动服务文件
[root@ Nginx1 process-exporter]# cd /etc/systemd/system/
[root@ Nginx1 system]# vi process_exporter.service

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

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/usr/local/process-exporter
ExecStart=/usr/local/process-exporter/process-exporter  --config.path=/usr/local/process-exporter/nginx.yaml
Restart=on-failure
[Install]
WantedBy=multi-user.target

5、启动服务,并设置开机自启
[root@ Nginx1 system]# systemctl daemon-reload
[root@ Nginx1 system]# systemctl start process_exporter.service
[root@ Nginx1 system]# systemctl status process_exporter.service
[root@ Nginx1 system]# systemctl enable process_exporter
6、防火墙开启端口
[root@ Nginx1 system]# firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=” 192.168.1.11" port port=“9256” protocol=“tcp” accept"
[root@ Nginx1 system]# firewall-cmd --reload
二、监控服务器上配置
1、编写配置文件
[root@dy-prometheus ~]# cd /usr/local/prometheus
[root@dy-prometheus prometheus]# vi scrapetarget.json

  {
    "targets": ["192.168.1.11:9256" ], (需要监控的主机IP)
    "labels": {
      "os": "Linux",
      "region": "test",
      "middleware": "nginx1_process"  (监控进程名,可自定义)
    }
  },
  {
    "targets": ["192.168.1.12:9256" ],
    "labels": {
      "os": "Linux",
      "region": "test",
      "middleware": "nginx2_process"
    }
  }

2、重启prometheus服务
[root@dy-prometheus prometheus]# systemctl restart prometheus
3、网页上查找相关数据
prometheus+process_exporter进程监控_第1张图片

你可能感兴趣的:(prometheus,prometheus,运维,服务器)