From 50d9795e6ef5c3f4a1ff58ed23708352706b7122 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 9 Aug 2023 02:04:29 +0200 Subject: [PATCH] nixos-module: add collectd postgresql metrics --- nixos-module.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nixos-module.nix b/nixos-module.nix index 358beb4..0fd3497 100644 --- a/nixos-module.nix +++ b/nixos-module.nix @@ -157,6 +157,30 @@ in GRANT ALL PRIVILEGES ON DATABASE caveman TO ${dbUser}; ''; }; + services.collectd.plugins.postgresql = '' + + Statement "select count(distinct host) from instance_tokens;" + + Type gauge + InstancePrefix "unique" + ValuesFrom "count" + + + + Statement "select count(*) from instance_tokens;" + + Type gauge + InstancePrefix "total" + ValuesFrom "count" + + + + + Param database "caveman" + Query total_tokens + Query hosts_with_tokens + + ''; systemd.services.caveman-hunter = lib.mkIf cfg.hunter.enable { wantedBy = [ "multi-user.target" ];