ops/nixos/lib/common: add nixos_running_system/nixos_booted_system node metrics
This commit is contained in:
parent
47c6327b4d
commit
9dd18e2cdc
1 changed files with 20 additions and 1 deletions
|
@ -149,7 +149,26 @@ in
|
|||
|
||||
services.prometheus.exporters.node = {
|
||||
enable = true;
|
||||
enabledCollectors = [ "systemd" ];
|
||||
enabledCollectors = [ "systemd" "textfile" ];
|
||||
extraFlags = [
|
||||
"--collector.textfile.directory=/run/prometheus-textfile-exports"
|
||||
];
|
||||
};
|
||||
system.activationScripts.node-exporter = {
|
||||
text = ''
|
||||
test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports
|
||||
my_version_string="$(cat "$systemConfig/nixos-version")"
|
||||
echo "nixos_running_system{version=\"$my_version_string\"} 1" > /run/prometheus-textfile-exports/running_system.prom
|
||||
'';
|
||||
};
|
||||
boot.postBootCommands = lib.mkAfter ''
|
||||
test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports
|
||||
my_version_string="$(cat "/run/booted-system/nixos-version")"
|
||||
echo "nixos_booted_system{version=\"$my_version_string\"} 1" > /run/prometheus-textfile-exports/booted_system.prom
|
||||
'';
|
||||
|
||||
system.nixos.tags = lib.mkBefore [
|
||||
depot.version
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue