working with nix

This commit is contained in:
Henry Hiles 2025-10-30 16:05:08 -04:00
commit e0f20e0e9d
No known key found for this signature in database
4 changed files with 81 additions and 199 deletions

59
lib/status.nix Normal file
View file

@ -0,0 +1,59 @@
{ pkgs, lib, ... }:
services:
pkgs.writers.writeJSON "status.json" {
title = "Service Status";
panels = map (
{ name, service }:
{
datasource = {
type = "prometheus";
uid = "prometheus";
};
fieldConfig = {
defaults = {
color = {
mode = "thresholds";
};
mappings = [
{
options = {
"0" = {
color = "red";
index = 1;
text = "Failed";
};
"1" = {
color = "green";
index = 0;
text = "Running";
};
};
type = "value";
}
];
thresholds = {
mode = "absolute";
steps = [
{
color = "red";
value = 0;
}
{
color = "green";
value = 1;
}
];
};
unit = "none";
};
};
targets = [
{
expr = "node_systemd_unit_state{name=\"${service}\",state=\"active\"}";
}
];
title = name;
type = "stat";
}
) services;
}