ops/nixos/lib/common: add the running system hash to the exported metrics
This commit is contained in:
parent
25372154af
commit
23eda90726
1 changed files with 8 additions and 2 deletions
|
@ -193,13 +193,19 @@ in
|
||||||
text = ''
|
text = ''
|
||||||
test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports
|
test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports
|
||||||
my_version_string="$(cat "$systemConfig/nixos-version")"
|
my_version_string="$(cat "$systemConfig/nixos-version")"
|
||||||
echo "nixos_running_system{version=\"$my_version_string\"} 1" > /run/prometheus-textfile-exports/running_system.prom
|
my_hash_string="$(readlink -f "$systemConfig" | grep -Eo '\b[0-9a-df-np-sv-z]{32}\b')"
|
||||||
|
echo "nixos_running_system{version=\"$my_version_string\", hash=\"$my_hash_string\"} 1" > /run/prometheus-textfile-exports/running_system.prom
|
||||||
|
|
||||||
|
my_version_string="$(cat "/run/booted-system/nixos-version")"
|
||||||
|
my_hash_string="$(readlink -f "/run/booted-system" | grep -Eo '\b[0-9a-df-np-sv-z]{32}\b')"
|
||||||
|
echo "nixos_booted_system{version=\"$my_version_string\", hash=\"$my_hash_string\"} 1" > /run/prometheus-textfile-exports/booted_system.prom
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
boot.postBootCommands = lib.mkAfter ''
|
boot.postBootCommands = lib.mkAfter ''
|
||||||
test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports
|
test -d /run/prometheus-textfile-exports || mkdir /run/prometheus-textfile-exports
|
||||||
my_version_string="$(cat "/run/booted-system/nixos-version")"
|
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
|
my_hash_string="$(readlink -f "/run/booted-system" | grep -Eo '\b[0-9a-df-np-sv-z]{32}\b')"
|
||||||
|
echo "nixos_booted_system{version=\"$my_version_string\", hash=\"$my_hash_string\"} 1" > /run/prometheus-textfile-exports/booted_system.prom
|
||||||
'';
|
'';
|
||||||
|
|
||||||
system.nixos.tags = lib.mkBefore [
|
system.nixos.tags = lib.mkBefore [
|
||||||
|
|
Loading…
Reference in a new issue