From 850f35dad9c8af939790059b789bdf3d3f2b4300 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 31 Mar 2023 20:21:04 +0200 Subject: [PATCH] buzzrelay: add collectd postgresql stats --- hosts/buzzrelay/default.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hosts/buzzrelay/default.nix b/hosts/buzzrelay/default.nix index 7a8f820a..db09b50e 100644 --- a/hosts/buzzrelay/default.nix +++ b/hosts/buzzrelay/default.nix @@ -41,7 +41,36 @@ package = pkgs.postgresql_15; settings.log_min_duration_statement = 50; upgrade.stopServices = [ "buzzrelay" ]; + ensureUsers = [ { + name = "collectd"; + ensurePermissions."DATABASE ${config.services.buzzrelay.database}" = "ALL PRIVILEGES"; + } ]; }; + + collectd.plugins.postgresql = '' + + Statement "select count(distinct id) from follows;" + + Type gauge + InstancePrefix "unique" + ValuesFrom "count" + + + + Statement "select count(id) from follows;" + + Type gauge + InstancePrefix "total" + ValuesFrom "count" + + + + + Param database "${config.services.buzzrelay.database}" + Query unique_followers + Query total_follows + + ''; }; system.stateVersion = "22.11";