Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active October 1, 2024 08:28
Show Gist options
  • Save gilangvperdana/49e7f66e2f0ddee0a7b5704bfe3d7911 to your computer and use it in GitHub Desktop.
Save gilangvperdana/49e7f66e2f0ddee0a7b5704bfe3d7911 to your computer and use it in GitHub Desktop.
Setup Proxmox Exporter & Visualize it to Grafana

General

Here is my experience installing Exporter on Proxmox and visualizing it on Grafana.

Install PVE Exporter

python3 -m pip install prometheus-pve-exporter

Add User

useradd --no-create-home --shell /bin/false pve_exporter

Create API Tokens

  • Go to proxmox dashboard -> Datacenter -> Unchecklist Permissions -> Api Token -> Add -> User: root@pam -> Token ID: exporter (please save) -> Add -> Save Secret Token.

Create Configuration File

mkdir /etc/pve_exporter
cat<<EOF > /etc/pve_exporter/config.yaml
default:
  user: root@pam
  token_name: exporter   #Token ID in First step
  token_value: 0e976bd7-ac9a-4d5d-8715-632bb44da1b0 #Secret Token in First step
  verify_ssl: false    
EOF

Create PVE Exporter Configruration

cat<<EOF > /etc/default/pve_exporter
CONFIG_FILE=/etc/pve_exporter/config.yaml
LISTEN_ADDR=172.20.1.30 #Your IP of PVE Exporters
LISTEN_PORT=9221
EOF

Create Systemd

cat<<EOF > /etc/systemd/system/pve_exporter.service
[Unit]
Description=PVE Expoter
Wants=network-online.target
After=network-online.target

[Service]
User=pve_exporter
Group=pve_exporter
Type=simple
EnvironmentFile=/etc/default/pve_exporter
ExecStart=pve_exporter \$CONFIG_FILE \$LISTEN_PORT \$LISTEN_ADDR 

[Install]
WantedBy=multi-user.target
EOF

Enable & Start

systemctl daemon-reload
systemctl enable --now pve_exporter

Testing

  • You can access on http://172.20.1.30:9221/pve?target=172.20.1.30

Prometheus.yml

  - job_name: 'pve'
    static_configs:
      - targets:
        - 172.20.1.30
    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: 172.20.1.30:9221

Grafana Dashboard

We can use template of Grafana Dashboard https://grafana.com/grafana/dashboards/10347-proxmox-via-prometheus/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment