aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2026-08-27 14:16:02 -0500
committerTim Keller <tjk@tjkeller.xyz>2026-08-27 14:16:02 -0500
commitca193ad52b2ee2985af079be0159cc679c914f02 (patch)
tree9e9d1e421b6b55f4735e4559c5b4a6c0055a80ba /README.md
parentd2d1386abb358fa547a40fc8df613d799155b56d (diff)
downloadtelemetry-flake-ca193ad52b2ee2985af079be0159cc679c914f02.tar.xz
telemetry-flake-ca193ad52b2ee2985af079be0159cc679c914f02.zip
generate the dashboards at build time instead of committing them
The JSON is machine-written and the generator beside it is the only source of truth, so committing both only created a way for them to drift -- which is what the dashboards-current check existed to police. modules/dashboards.nix now runs gen_zfs.py / gen_smart.py in the derivation, so a stale dashboard cannot be built at all and the check is gone. Note there is no third option: flakes copy only git-tracked files into the store, so a gitignored dashboards/*.json cannot be read from disk either. It is generate, or commit. Verified equivalent -- both generated dashboards are byte-identical to the JSON this commit deletes. Adds a dashboards-nonempty check. Factoring the shared jq invocation out first introduced a bug it caught: the multi-line string ended in a newline, so the callers' `< $src > "$out"` landed on a line of its own as a separate command, truncating every dashboard to zero bytes while the build still succeeded. All four provisioned dashboards were empty. jqFixup is now a single line, and the check asserts each dashboard is non-empty and has a title, uid and panels. Both failure modes are exercised: an empty dashboard and one with no panels each fail the check. It also asserts it found four files, because the first version globbed *.json against linkFarm entries named without the suffix and passed vacuously. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JKczN1f66kmLxNBLX37voQ
Diffstat (limited to 'README.md')
-rw-r--r--README.md17
1 files changed, 9 insertions, 8 deletions
diff --git a/README.md b/README.md
index 7bcea7f..9014e1b 100644
--- a/README.md
+++ b/README.md
@@ -17,8 +17,7 @@ What *has* been checked:
- every dashboard query executed against a real Prometheus fed fixture data
- `promtool` over the recording rules and the generated scrape config
-- `nix flake check`: both modules evaluate, and the committed dashboard JSON matches what
- the generators produce
+- `nix flake check`: both modules evaluate, and both dashboard generators run
- the collectors run against mock `smartctl`/`zpool`/`zfs`, and partially against real
hardware
@@ -225,21 +224,23 @@ modules/
dashboards.nix builds dashboard JSON into a provisionable form
packages.nix the two collectors as ordinary packages
collectors/*.py the collectors themselves; runnable by hand
-dashboards/gen_*.py dashboard generators
-dashboards/*.json generated, committed, checked
+dashboards/gen_*.py dashboard generators; the JSON is built, not committed
rules/smartctl.yml Prometheus recording rules
```
## Working on it
-Dashboard JSON is **generated** — edit `dashboards/gen_*.py`, never the JSON:
+The ZFS Pools and Drive Health dashboards are **generated at build time** from
+`dashboards/gen_*.py`; no JSON is committed, so there is nothing to keep in sync and no
+way to ship a stale dashboard. To see what a generator currently produces:
```sh
-python3 dashboards/gen_zfs.py > dashboards/zfs-pools.json
-python3 dashboards/gen_smart.py > dashboards/smart.json
+python3 dashboards/gen_zfs.py | less
+nix build .#nixosConfigurations.<host>.config.system.build.toplevel # or just deploy
```
-`nix flake check` fails if you forget.
+(Flakes copy only git-tracked files into the store, so "gitignore the JSON and read it
+from disk anyway" is not an option — it is generate, or commit.)
The collectors are plain scripts taking `--output PATH`, so you can see exactly what a
machine reports: