prometheus 进程的监控
1. process exporter功能
2. 监控目标对主机进程的监控,chronyd sshd 等服务进程已经已定义脚本运行程序的运行状态监控。
process-compose的安装
监控所有进程
mkdir /data/process_exporter -p
cd /data/process_exporter
创建配置文件
监控所有进程
```
cat >>process.yml<< 'EOF'
process_names:
- name: "{{ .Comm}}" #匹配模板
cmdline:
- '.+' #匹配所有名称
EOF
```
监控指定进程
cat >>process.yml<< 'EOF'
process_names:
# - name: "{{ .Comm}}" #匹配模板
# cmdline:
# - '.+' #匹配所有名称
- name: "{{.Matches}}"
cmdline:
- 'mongod'
- name: "{{.Matches}}"
cmdline:
- 'mysqld'
- name: "{{.Matches}}"
cmdline:
- 'nginx' #唯一标识
- name: "{{.Matches}}"
cmdline:
- 'redis-server'
EOF
docker 运行
cd /data/process_exporter/
docker run -d --rm -p 9256:9256 \
--privileged -v /proc:/host/proc -v `pwd`:/config \
--name process-exporter \
ncabatoff/process-exporter:0.7.10 \
--procfs /host/proc -config.path /config/process.yml
docker ps -a 确认 up
http://10.19.1.220:9256/metrics
增加prometheus.yml 配置
- job_name: 'process-exporter'
scrape_interval: 30s
scrape_timeout: 15s
static_configs:
- targets: ['10.19.1.220:9256']
labels:
instance: process服务器
curl -X POST http://localhost:9090/-/reload
触发器
cat >>prometheus/rules/process.yml << 'EOF'
groups:
- name: process
rules:
- alert: 进程数多告警
expr: sum(namedprocess_namegroup_states) by (instance) > 1000
for: 1m
labels:
severity: warning
annotations:
description: "服务器当前值有{{ $value }}个进程"
EOF
curl -X POST http://localhost:9090/-/reload
添加dashboard
文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/10815