在创建一个Proxmox创建一个 api用户类型
并设置权限
pveum roleadd Monitoring
pveum rolemod Monitoring --privs Sys.Modify,VM.Monitor,Sys.Audit,Datastore.Audit,VM.Audit
创建一个叫monitoring的用户并设置密码
pveum useradd monitoring@pve --comment "The ICINGA 2 monitoring user"
pveum useradd prometheus@pve --comment "The prometheus monitoring user"
pveum passwd prometheus@pve
pveum passwd monitoring@pve
给用户指派角色
pveum aclmod / -user monitoring@pve -role Monitoring
pveum aclmod / -user prometheus@pve -role Monitoring
当然,这些也都可以在pve图形操作
然后安装pve的Prometheus客户端
首先安装pip客户端
apt-get install -y python-pip
然后安装pve的Prometheus客户端
pip install prometheus-pve-exporter
找一下安装到哪里去了?
root@proxmox01s:~# whereis pve_exporter
pve_exporter: /usr/local/bin/pve_exporter
添加到pve 的systemd 里面,用于开机启动
cat <<EOF> /etc/systemd/system/prometheus-pve-exporter.service
[Unit]
Description=Prometheus exporter for Proxmox VE
Documentation=https://github.com/znerol/prometheus-pve-exporter
[Service]
Restart=always
User=prometheus@pve
#ExecStart=/opt/prometheus-pve-exporter/bin/pve_exporter /etc/prometheus/pve.yml
ExecStart= /usr/local/bin/pve_exporter /etc/prometheus/pve.yml
[Install]
WantedBy=multi-user.target
EOF
上面注释掉的是如果你才用python的虚拟环境的话,一般会装到opt这个目录去
启动服务的用户,要和创建的一致
User=prometheus@pve
然后创建pve.yml文件
default:
user: prometheus@pve
password: yourpassword
verify_ssl: false
密码是刚刚你创建的密码
启动prometheus-pve-exporter,
如非特别指定,默认跑到9221
systemctl daemon-reload
systemctl start prometheus-pve-exporter
然后配置,根据你的 PVE exporter在哪里运行,决定推或者拉的方式,使用不同的配置文件。
Example config for PVE exporter running on PVE node:
scrape_configs:
- job_name: 'pve'
static_configs:
- targets:
- 192.168.1.2:9221 # Proxmox VE node with PVE exporter.
- 192.168.1.3:9221 # Proxmox VE node with PVE exporter.
metrics_path: /pve
params:
module: [default]
Example config for PVE exporter running on Prometheus host:
scrape_configs:
- job_name: 'pve'
static_configs:
- targets:
- 192.168.1.2 # Proxmox VE node.
- 192.168.1.3 # Proxmox VE node.
metrics_path: /pve
params:
module: [default]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9221 # PVE exporter.
参考文档
https://github.com/nbuchwitz/check_pve
https://github.com/znerol/prometheus-pve-exporter
网友评论