1.创建用户
groupadd --system prometheus
useradd -s /sbin/nologin --system -g prometheus prometheus
mkdir /etc/prometheus/
2.安装软件
--break-system-packages
选项的作用是告诉pip忽略当前环境的外部管理,并强制安装Python包到当前环境中。这对于在特定环境中管理Python包非常有用,比如虚拟环境或用户级别的Python包管理。
apt install python3 python3-pip
pip3 install prometheus-pve-exporter --break-system-packages
3.创建配置文件
vi /etc/prometheus/pve.yml
4.填入下面的内容
pve宿主机的账号密码
default:
user: root@pam
password: your_password_here
verify_ssl: false
5.设置权限
chown -R prometheus:prometheus /etc/prometheus/
chmod -R 775 /etc/prometheus/
6.创建systemed
第四行可以注释掉
tee /etc/systemd/system/prometheus-pve-exporter.service<<EOF
[Unit]
Description=Prometheus exporter for Proxmox VE
#Documentation=https://github.com/znerol/prometheus-pve-exporter
[Service]
Restart=always
User=prometheus
ExecStart=/usr/local/bin/pve_exporter --config.file /etc/prometheus/pve.yml
[Install]
WantedBy=multi-user.target
EOF
7.设置开机启动
systemctl daemon-reload
systemctl start prometheus-pve-exporter
systemctl enable prometheus-pve-exporter
此时输入pve_ip:9221/pve 。就可以进入一个页面
8.在prometheus上面添加监控配置
vi /etc/prometheus/prometheus.yml
在最后写入
- job_name: 'proxmox'
metrics_path: /pve
static_configs:
- targets: ['10.13.14.2:9221']
注意,在target处,替换自己的pve_ip。同时注意格式,对齐。
重启一下服务
systemctl restart prometheus
说明:关注grafana+prometheus安装配置这里不说明,服务器监控可以使用node-exporter客户端