https://github.com/boinkor-net/zpool-exporter-textfile
A tool to export zpool metrics as prometheus metric textfiles
https://github.com/boinkor-net/zpool-exporter-textfile
nixos node-exporter prometheus rust zfs zpool
Last synced: 11 months ago
JSON representation
A tool to export zpool metrics as prometheus metric textfiles
- Host: GitHub
- URL: https://github.com/boinkor-net/zpool-exporter-textfile
- Owner: boinkor-net
- License: apache-2.0
- Created: 2021-02-12T21:03:31.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-14T23:02:08.000Z (about 2 years ago)
- Last Synced: 2024-04-18T04:09:57.452Z (about 2 years ago)
- Topics: nixos, node-exporter, prometheus, rust, zfs, zpool
- Language: Nix
- Homepage: https://github.com/boinkor-net/zpool-exporter-textfile
- Size: 158 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://circleci.com/gh/antifuchs/zpool-exporter-textfile) [](https://docs.rs/zpool-exporter-textfile/) [](https://crates.io/crates/zpool-exporter-textfile)
# zpool-exporter-textfile
This program can export metrics about the health of ZFS zpools into a text file that can be picked up by prometheus's node_collector via the textfile collector.
## Usage
You'll want to regularly run this program. It automatically collects data about all active zpools.
```
$ zpool-exporter-textfile -o .../zpool_stats.txt
```
## Installation
To build this, you need `libzfs`, as that's a compile time dependency. If you use nix, the included flake.nix will result in a binary that you can use.
### Use in a flake
You can use this in a flake like so (I hope!):
```nix
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
zpool-exporter.url = "github:antifuchs/zpool-exporter-textfile";
};
outputs = { zpool-exporter, nixpkgs, ... }: {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
./configuration.nix
zpool-exporter.nixosModules.zpool-exporter-textfile
{config, ...}: {
zpool-exporter-textfile = {
enable = true;
textfileDir = "node_exporter_textfiles";
};
services.prometheus.exporters.node.extraFlags = [
"--collector.textfile.directory=/etc/node_exporter_textfiles/"
];
}
];
};
};
};
}
```
## Example metrics
```txt
# HELP zpool_health_level Overall health level of a pool. 0 if unhealthy, 1 if healthy.
# TYPE zpool_health_level gauge
zpool_health_level{pool="bpool"} 1
zpool_health_level{pool="data"} 1
zpool_health_level{pool="rpool"} 1
# HELP zpool_health_state Health status (1 if the is at health )
# TYPE zpool_health_state gauge
zpool_health_state{pool="bpool",state="Available"} 0
zpool_health_state{pool="bpool",state="Degraded"} 0
zpool_health_state{pool="bpool",state="Faulted"} 0
zpool_health_state{pool="bpool",state="Offline"} 0
zpool_health_state{pool="bpool",state="Online"} 1
zpool_health_state{pool="bpool",state="Removed"} 0
zpool_health_state{pool="bpool",state="Unavailable"} 0
zpool_health_state{pool="data",state="Available"} 0
zpool_health_state{pool="data",state="Degraded"} 0
zpool_health_state{pool="data",state="Faulted"} 0
zpool_health_state{pool="data",state="Offline"} 0
zpool_health_state{pool="data",state="Online"} 1
zpool_health_state{pool="data",state="Removed"} 0
zpool_health_state{pool="data",state="Unavailable"} 0
zpool_health_state{pool="rpool",state="Available"} 0
zpool_health_state{pool="rpool",state="Degraded"} 0
zpool_health_state{pool="rpool",state="Faulted"} 0
zpool_health_state{pool="rpool",state="Offline"} 0
zpool_health_state{pool="rpool",state="Online"} 1
zpool_health_state{pool="rpool",state="Removed"} 0
zpool_health_state{pool="rpool",state="Unavailable"} 0
```