This how-to will take you through setting up Proxmox (PVE) to send logged data to InfluxDB and then access it in Grafana. This will give you access to longer term data logging, statisics and analytics, which allows you to see long term visualizations and trends.
Prerequisistes
This guide assumes you have Proxmox and Docker already setup.
Guide
- Setup InfluxDB in Docker
- Under sources, follow “Install InfluxDB using Docker Compose”
- Change “DOCKER_INFLUXDB_INIT_ORG” to what you would like your organization name to be.
- Change “DOCKER_INFLUXDB_INIT_BUCKET” to “proxmox”
- Create a bucket to store data in
This is only needed if you do not want to use the bucket automatically created in the previous step or you already have an InfluxDB instance running.- Log into InfluxDB
- On the left, go to Load Data > Buckets
- On the right, click on Create Bucket
- Enter a name and select a retention period
Consider retention periods carefully, as the data and database size can grow quickly, depending on setup.
- Create an API token for proxmox with write access to the bucket
Best practices is to create a dedicated API token for each service accessing the bucket with restricted permissions- On the left, go to Load Data > API Tokens
- On the right, click on ”+ Generate API Token”
- Give the token a meaningful description (Proxmox Access)
- Under “Buckets” find the bucket you will store Proxmox data in, then check off “Write”
- Click “Generate” at the bottom
- Copy the API token, once the box is closed, you will not be able to access it again.
- Send data from Proxmox to InfluxDB
- Log into Proxmox with an account that has admin permissions
- On the left, go to Datacenter > Metric Server
- At the top, click Add > InfluxDB
- Add the details for your setup:
- Name: Name for your InfluxDB server
- Server: IP of the docker host
- Port: 8086
- Protocol: HTTP
- Organization: Name of the organization in InfluxDB
- Bucket: This is the bucket created above.
- Token: This is the token created above
- Setup Grafana in Docker
- Under sources, follow “Run Grafana Docker image”
- Change the image to “grafana/grafana-oss” if you do not have an enterprise license
- Add the depends on section from the example below (optional)
- Create an API token for Grafana with read access
Best practices is to create a dedicated API token for each service accessing the bucket with restricted permissions
- Go back to InfluxDB
- On the left, go to Load Data > API Tokens
- On the right, click on + Generate API Token > Custom API Token
- Give the token a meaningful description (Grafana)
- Under “Buckets” find the bucket you will want to display graph data from, then check off “Read”
Alternatively, check off Read next to “All Buckets” - Click “Generate” at the bottom
- Copy the API token, once the box is closed, you will not be able to access it again.
- Add InfluxDB to Grafana
- Log into Grafana
- On the left, go to Connections > Add new connection
- Filter by “InfluxDB” and click on it
- At the top, change the query language to Flux
- Fill in the details for your setup
- HTTP:
- URL: http://CONTAINER_NAME:8086
- Auth: Uncheck all of them
- InfluxDB Details:
- Organization: The name of your organization (not the hex ID rom above)
- Token: The token generated in the previous step
- Default Bucket: Leave blank to pull all buckets, specify a bucket to read data from
- HTTP:
- Click “Save & Test” at the bottom to confirm your setup works.
You should now be ready to start building dashboards in Grafana with data from Proxmox.
Config files
Docker config.yml
services:
influxdb2:
container_name: influxdb
image: influxdb:2
ports:
- 8086:8086
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME_FILE: /run/secrets/influxdb2-admin-username
DOCKER_INFLUXDB_INIT_PASSWORD_FILE: /run/secrets/influxdb2-admin-password
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN_FILE: /run/secrets/influxdb2-admin-token
DOCKER_INFLUXDB_INIT_ORG: orion_tech
DOCKER_INFLUXDB_INIT_BUCKET: home_assistant
secrets:
- influxdb2-admin-username
- influxdb2-admin-password
- influxdb2-admin-token
volumes:
- type: volume
source: influxdb2-data
target: /var/lib/influxdb2
- type: volume
source: influxdb2-config
target: /etc/influxdb2
grafana:
image: grafana/grafana-oss
container_name: grafana
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- grafana-storage:/var/lib/grafana
depends_on:
- influxdb2
secrets:
# these files are in the root account's home folder
influxdb2-admin-username:
file: ~/.env.influxdb2-admin-username
influxdb2-admin-password:
file: ~/.env.influxdb2-admin-password
influxdb2-admin-token:
file: ~/.env.influxdb2-admin-token
volumes:
influxdb2-data:
influxdb2-config:
grafana-storage: