Open martijndierckx opened 1 year ago
Hi @martijndierckx
Do you mean listing space usage for datasets, not just for the pools?
Funny thing, I was trying to solve this at my work recently. As far I could have searched, there was not an easy way to get ZFS dataset space usage programmatically. And, none of the following applications support it: NetData, InfluxDB Telegraf ZFS plugin, CollectD with ZFS plufin, node_exporter, zpool_influxdb CLI.
What I ended up doing is using InfluxDB Telegraf with exec input type and calling a custom bash script that takes an output from zfs get -p -H all
, transforms each line a little bit (removing whitespace, adding {}, etc.), and echoes such metrics in a Prometheus format.
Unfortunately this is not possible with the libzfs
Python library used in this project. However, I could write something that calls the zfs list -o space
via a shell from the Python code and exposes the metrics that way.
This could be added as zfsprom_list_xyz
metrics with tag dataset=...
, while the original ones such as zfsprom_size
would stay as they are. I would prefer to keep the original metrics unchanged so it won't cause any issues for the existing users.
Right now I am busy with other things. I can come back to this in ~2 weeks and implement it. However, if you need this sooner then feel free to submit a PR :)
Sounds like a plan! Other approach would be to ask to implement this on libzfs? I do find it weird however that this information is nowhere available. It can't possibly be that we're the first to think of this ...
Sorry for a late update. My life got busy.
I have been trying to include the output of zfs list -o space
, but I am no longer able to successfully built the Docker image. It seems that the recent version of some package (either the newer py-libzfs from TrueNAS or some Python/Cython package) broke the build.
I will not implement this feature.
I suggest that you should look into the zpool_influxdb CLI which should be located here: /usr/lib/zfs-linux/zpool_influxdb
if you are using the latest ZFS debian package on the Ubuntu.
You can use the InfluxDB Telegraf with the exec plugin to read the metrics. Essentially, the plugin expects that the binary will print the metrics in InfluxDB format to the stdout, which is exactly what the zpool_influxdb
does. It works out of the box. You can then use any of the output plugins to send the metrics forward, or even expose them as Prometheus metrics on some HTTP port.
The zpool_influxdb
is far more useful and powerful than this prometheus-zfs project.
My goal is to follow up on the available space of my pools in prometheus. I have available:
zfsprom_alloc
,zfsprom_size
andzfsprom_free
.However, these values are on physical pool level as reported byzpool list
. And thus not very reliable in day-to-day usage.I would like to follow up on the
available
andused
(+calculated total) values as reported byzfs list -o space
. Is this info available? If not, can it be made available?