From 485d3201305087b424aa25b44a3dbf401079541b Mon Sep 17 00:00:00 2001 From: Shaun Davis Date: Fri, 3 Mar 2023 15:15:09 -0600 Subject: [PATCH 1/4] Add missing dashboard metrics --- cmd/start/main.go | 1 + config/queries.yaml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/cmd/start/main.go b/cmd/start/main.go index 172e1f71..7836506b 100644 --- a/cmd/start/main.go +++ b/cmd/start/main.go @@ -74,6 +74,7 @@ func main() { "DATA_SOURCE_PASS": node.SUCredentials.Password, "PG_EXPORTER_EXCLUDE_DATABASE": "template0,template1", "PG_EXPORTER_AUTO_DISCOVER_DATABASES": "true", + "PG_EXPORTER_EXTEND_QUERY_PATH": "/fly/queries.yaml", } svisor.AddProcess("exporter", "postgres_exporter --log.level=warn ", supervisor.WithEnv(exporterEnv), diff --git a/config/queries.yaml b/config/queries.yaml index d42ab213..093781fd 100644 --- a/config/queries.yaml +++ b/config/queries.yaml @@ -9,3 +9,17 @@ pg_database: - size_bytes: usage: "GAUGE" description: "Disk space used by the database" + +pg_replication: + query: "SELECT slot_name, active, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS lag FROM pg_replication_slots;" + master: true + metrics: + - slot_name: + usage: "LABEL" + description: "Name of replication slot" + - active: + usage: "LABEL" + description: "Whether the replication slot is active" + - lag: + usage: "GAUGE" + description: "Replication lag in bytes" From 921c09f3e89146a7fcf2189c467796d6fff6f30f Mon Sep 17 00:00:00 2001 From: Shaun Davis Date: Fri, 3 Mar 2023 15:16:26 -0600 Subject: [PATCH 2/4] cache query for 30 seconds --- config/queries.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/queries.yaml b/config/queries.yaml index 093781fd..0b7a2d2d 100644 --- a/config/queries.yaml +++ b/config/queries.yaml @@ -13,6 +13,7 @@ pg_database: pg_replication: query: "SELECT slot_name, active, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS lag FROM pg_replication_slots;" master: true + cache_seconds: 30 metrics: - slot_name: usage: "LABEL" From e5108402779eb5797e423adc56e6be36a42338d1 Mon Sep 17 00:00:00 2001 From: Shaun Davis Date: Fri, 3 Mar 2023 15:34:38 -0600 Subject: [PATCH 3/4] Cast bool to string --- config/queries.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/queries.yaml b/config/queries.yaml index 0b7a2d2d..12d796b9 100644 --- a/config/queries.yaml +++ b/config/queries.yaml @@ -11,7 +11,7 @@ pg_database: description: "Disk space used by the database" pg_replication: - query: "SELECT slot_name, active, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS lag FROM pg_replication_slots;" + query: "SELECT slot_name, CAST(active AS TEXT), pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS lag FROM pg_replication_slots" master: true cache_seconds: 30 metrics: @@ -22,5 +22,5 @@ pg_replication: usage: "LABEL" description: "Whether the replication slot is active" - lag: - usage: "GAUGE" - description: "Replication lag in bytes" + usage: "GAUGE" + description: "Replication lag in bytes" From 9902999101c2fb53208f1b76bf25498eee3b863b Mon Sep 17 00:00:00 2001 From: Shaun Davis Date: Fri, 3 Mar 2023 15:58:48 -0600 Subject: [PATCH 4/4] Will have to handle pg_replication at different time --- config/queries.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/config/queries.yaml b/config/queries.yaml index 12d796b9..ec7882ba 100644 --- a/config/queries.yaml +++ b/config/queries.yaml @@ -10,17 +10,17 @@ pg_database: usage: "GAUGE" description: "Disk space used by the database" -pg_replication: - query: "SELECT slot_name, CAST(active AS TEXT), pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS lag FROM pg_replication_slots" - master: true - cache_seconds: 30 - metrics: - - slot_name: - usage: "LABEL" - description: "Name of replication slot" - - active: - usage: "LABEL" - description: "Whether the replication slot is active" - - lag: - usage: "GAUGE" - description: "Replication lag in bytes" +# pg_replication: +# query: "SELECT slot_name, CAST(active AS TEXT), pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS lag FROM pg_replication_slots" +# master: true +# cache_seconds: 30 +# metrics: +# - slot_name: +# usage: "LABEL" +# description: "Name of replication slot" +# # - active: +# # usage: "LABEL" +# # description: "Whether the replication slot is active" +# - lag: +# usage: "GAUGE" +# description: "Replication lag in bytes"