working with nix
This commit is contained in:
parent
dfe7918cdb
commit
e0f20e0e9d
4 changed files with 81 additions and 199 deletions
59
lib/status.nix
Normal file
59
lib/status.nix
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue