Merge branch 'nix': quieter access-file alert
All checks were successful
nixos / nixos (push) Successful in 1m19s

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 09:59:55 +04:00
commit c543214c20
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
2 changed files with 15 additions and 1 deletions

View file

@ -325,7 +325,8 @@ groups:
- refId: A
relativeTimeRange: { from: 900, to: 0 }
datasourceUid: prometheus
model: { refId: A, expr: "changes(security_fileset_hash[15m])", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
# Not within 20 minutes of a NixOS activation: deploys rewrite accounts and authorized_keys
model: { refId: A, expr: "changes(security_fileset_hash[15m]) unless on(host) (time() - nixos_activation_timestamp_seconds < 1200)", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
- refId: C
datasourceUid: __expr__
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }

View file

@ -190,6 +190,19 @@ in
systemd.tmpfiles.rules = [ "d ${textfile} 0755 root root -" ];
# When this host last activated a NixOS configuration (deploy or
# boot). Activations rewrite accounts and authorized_keys by design;
# the "Access files changed" alert stays quiet around them and still
# fires for a change outside a deploy, which here means a hand edit.
system.activationScripts.activationMetric = {
deps = [ ];
text = ''
mkdir -p ${textfile}
printf '# HELP nixos_activation_timestamp_seconds Last NixOS activation (deploy or boot).\n# TYPE nixos_activation_timestamp_seconds gauge\nnixos_activation_timestamp_seconds %s\n' "$(${pkgs.coreutils}/bin/date +%s)" > ${textfile}/nixos.prom.tmp
mv ${textfile}/nixos.prom.tmp ${textfile}/nixos.prom
'';
};
services.prometheus.exporters.node = {
enable = true;
listenAddress = ip;