| 1 | { |
| 2 | pkgs, |
| 3 | ... |
| 4 | }: |
| 5 | { |
| 6 | services.prometheus = { |
| 7 | scrapeConfigs = [ |
| 8 | { |
| 9 | job_name = "zfs"; |
| 10 | static_configs = [ |
| 11 | { |
| 12 | targets = [ |
| 13 | "haumea.nixos.org:9134" |
| 14 | "mimas.nixos.org:9134" |
| 15 | "pluto.nixos.org:9134" |
| 16 | "titan.nixos.org:9134" |
| 17 | ]; |
| 18 | } |
| 19 | ]; |
| 20 | } |
| 21 | ]; |
| 22 | ruleFiles = [ |
| 23 | (pkgs.writeText "node-exporter.rules" ( |
| 24 | builtins.toJSON { |
| 25 | groups = [ |
| 26 | { |
| 27 | name = "zfs"; |
| 28 | rules = [ |
| 29 | { |
| 30 | alert = "ZfsPoolHealth"; |
| 31 | expr = '' |
| 32 | zfs_pool_health > 0 |
| 33 | ''; |
| 34 | for = "5m"; |
| 35 | labels.severity = "WARNING"; |
| 36 | annotations.summary = "ZFS pool {{ $labels.pool }} on {{ $labels.instance }} is unhealthy."; |
| 37 | } |
| 38 | { |
| 39 | alert = "ZfsPoolFull"; |
| 40 | expr = '' |
| 41 | round((zfs_pool_free_bytes / zfs_pool_size_bytes) * 100, 1) < 15 |
| 42 | ''; |
| 43 | for = "30m"; |
| 44 | labels.severity = "warning"; |
| 45 | annotations.summary = "ZFS pool {{ $labels.pool }} on {{ $labels.instance }} has only {{ $value }}% free space."; |
| 46 | annotations.grafana = "https://grafana.nixos.org/d/rYdddlPWk/node-exporter-full?orgId=1&var-job=node&var-node={{ $labels.instance }}"; |
| 47 | } |
| 48 | ]; |
| 49 | } |
| 50 | ]; |
| 51 | } |
| 52 | )) |
| 53 | ]; |
| 54 | }; |
| 55 | } |