prometheus-zfs
prometheus-zfs copied to clipboard
Prometheus exporter for (some) ZFS statistics via zpool iostatus and zfs get space
Prometheus ZFS metrics exporter
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
Why?
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.
Install
- Make sure you have successfully built and installed (run make install as sudo!) the py-libzfs library.
- Copy the
zfsprom.servicefile into/etc/systemd/systemfolder. - Copy the
zfsprom.pyfile anywhere into your system. - Modify
ExecStart=in thezfsprom.serviceso that it points tozfsprom.pyin your system. - Run
chmod +x zfsprom.py - Install
prometheus_clientfor the root user, example:sudo -H python3 -m pip install prometheus_client - Run
systemctl enable zfspromandsystemctl start zfsprom - Your metrics will now be available at
http://localhost:9901
Ports
FreeBSD
Docker Usage
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