aboutsummaryrefslogtreecommitdiff
path: root/nixos/shared/postgres-collectors.nix
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-09-18 08:45:19 +0200
committerMartin Fischer <martin@push-f.com>2025-09-20 14:40:47 +0200
commit0d53b5617f165bd33c5db7f5355bb51a46e26b16 (patch)
tree43dd371eb47feb239a73ca8d68eabcf2ae630f03 /nixos/shared/postgres-collectors.nix
parent21fdce7d65f46c9935f0bf1b9475c8bcd28abf47 (diff)
refactor: make db-size collector reusable
Diffstat (limited to 'nixos/shared/postgres-collectors.nix')
-rw-r--r--nixos/shared/postgres-collectors.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/nixos/shared/postgres-collectors.nix b/nixos/shared/postgres-collectors.nix
new file mode 100644
index 0000000..fd44cb0
--- /dev/null
+++ b/nixos/shared/postgres-collectors.nix
@@ -0,0 +1,22 @@
+# collectors for the prometheus-sql-exporter
+{ config, lib, pkgs, ... }:
+
+{
+ collectorNames = ["db-sizes"];
+
+ collectors = [
+ {
+ collector_name = "db-sizes";
+ metrics = [
+ {
+ metric_name = "pg_db_size_bytes";
+ help = "disk space used by the database";
+ type = "gauge";
+ key_labels = ["database_name"];
+ values = ["size"];
+ query = "SELECT datname AS database_name, pg_database_size(datname) as size from pg_database";
+ }
+ ];
+ }
+ ];
+}