| 1 | { |
| 2 | config, |
| 3 | pkgs, |
| 4 | ... |
| 5 | }: |
| 6 | { |
| 7 | age.secrets."storagebox-exporter-token".file = ../../../secrets/storagebox-exporter-token.age; |
| 8 | |
| 9 | services.prometheus = { |
| 10 | exporters.storagebox = { |
| 11 | enable = true; |
| 12 | listenAddress = "localhost"; |
| 13 | tokenFile = config.age.secrets."storagebox-exporter-token".path; |
| 14 | }; |
| 15 | |
| 16 | scrapeConfigs = [ |
| 17 | { |
| 18 | job_name = "storagebox"; |
| 19 | scheme = "http"; |
| 20 | static_configs = [ { targets = [ "localhost:9509" ]; } ]; |
| 21 | } |
| 22 | ]; |
| 23 | |
| 24 | ruleFiles = [ |
| 25 | (pkgs.writeText "storagebox-exporter.rules" ( |
| 26 | builtins.toJSON { |
| 27 | groups = [ |
| 28 | { |
| 29 | name = "storagebox"; |
| 30 | rules = [ |
| 31 | { |
| 32 | alert = "StorageboxCapacity"; |
| 33 | expr = "round(100 * (1 - (storagebox_disk_usage / storagebox_disk_quota))) < 10"; |
| 34 | for = "30m"; |
| 35 | labels.severity = "warning"; |
| 36 | annotations.summary = "StorageBox {{ $labels.name }} ({ $labels.server }}) has less than {{ $value }}% free space."; |
| 37 | } |
| 38 | ]; |
| 39 | } |
| 40 | ]; |
| 41 | } |
| 42 | )) |
| 43 | ]; |
| 44 | }; |
| 45 | } |