From 837c68b6dfbaba69e987f2d6440a968a88bb9ba5 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Thu, 14 Nov 2024 10:20:27 -0600 Subject: [PATCH] Track application_name in connection_counts metric It will help us understand what applications are exhausting the number of direct database connections. Signed-off-by: Tristan Partin --- compute/etc/sql_exporter/connection_counts.libsonnet | 1 + compute/etc/sql_exporter/connection_counts.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compute/etc/sql_exporter/connection_counts.libsonnet b/compute/etc/sql_exporter/connection_counts.libsonnet index 9f94db67a9..09a0154277 100644 --- a/compute/etc/sql_exporter/connection_counts.libsonnet +++ b/compute/etc/sql_exporter/connection_counts.libsonnet @@ -4,6 +4,7 @@ help: 'Connection counts', key_labels: [ 'datname', + 'application_name', 'state', ], values: [ diff --git a/compute/etc/sql_exporter/connection_counts.sql b/compute/etc/sql_exporter/connection_counts.sql index 6824480fdb..2f3163d2b0 100644 --- a/compute/etc/sql_exporter/connection_counts.sql +++ b/compute/etc/sql_exporter/connection_counts.sql @@ -1 +1 @@ -SELECT datname, state, count(*) AS count FROM pg_stat_activity WHERE state <> '' GROUP BY datname, state; +SELECT datname, application_name, state, count(*) AS count FROM pg_stat_activity WHERE state <> '' GROUP BY datname, state;