NOTE!!! This project is currently unable to be built due to a newer Cython and compilation issues as stated in truenas/py-libzfs#249 . I highly recommend using zpool_influxdb instead!
This is a simple exporter for the Prometheus metrics for zfs by utilizing py-libzfs. The script zfsprom.py
also comes with zfsprom.service
so that you can run this script in the background on your Linux OS via systemctl
. The script will listen on 0.0.0.0:9901
by default. You can use the --port
and --addr
command line flags to change this.
This python script only exports the following metrics:
- active - Enum, zfsprom_active, Active state (ACTIVE, EXPORTED, DESTROYED, etc...)
- size - Gauge, zfsprom_size, Size (bytes)
- alloc - Gauge, zfsprom_alloc, Allocated space (bytes)
- free - Gauge, zfsprom_free, Free space (bytes)
- op_read - Gauge, zfsprom_op_read, Operations read
- op_write - Gauge, zfsprom_op_write, Operations write
- bw_read - Gauge, zfsprom_bw_read, Bandwidth read (bytes)
- bw_write - Gauge, zfsprom_bw_write, Bandwidth write (bytes)
- errors_read - Gauge, zfsprom_errors_read, Read errors
- errors_write - Gauge, zfsprom_errors_write, Write errors
- errors_cksum - Gauge, zfsprom_errors_cksum, Checksum errors
- status - Enum, zfsprom_disk_status, Disk status', (ONLINE, OFFLINE, etc...)
Docker image here: https://hub.docker.com/r/matusnovak/prometheus-zfs
The node-exporter for Prometheus does a very good job at exporting most of the ZFS metrics, but this script exports the ones that can not be obtained via node-exporter, such as available space.
- Make sure you have successfully built and installed (run make install as sudo!) the py-libzfs library.
- Copy the
zfsprom.service
file into/etc/systemd/system
folder. - Copy the
zfsprom.py
file anywhere into your system. - Modify
ExecStart=
in thezfsprom.service
so that it points tozfsprom.py
in your system. - Run
chmod +x zfsprom.py
- Install
prometheus_client
for the root user, example:sudo -H python3 -m pip install prometheus_client
- Run
systemctl enable zfsprom
andsystemctl start zfsprom
- Your metrics will now be available at
http://localhost:9901
version: '3'
services:
zfs-metrics:
image: matusnovak/prometheus-zfs:latest
restart: unless-stopped
privileged: true
ports:
- 9901:9901
Your metrics will be available at http://localhost:9901/metrics