From e6bc478cb154ad9aef90051a91384358a3f6a029 Mon Sep 17 00:00:00 2001 From: Christopher Anciaux Date: Mon, 23 Dec 2024 15:07:28 +0100 Subject: [PATCH 1/2] add partition_of metric tag --- postgres/datadog_checks/postgres/relationsmanager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/postgres/datadog_checks/postgres/relationsmanager.py b/postgres/datadog_checks/postgres/relationsmanager.py index 1952534049e1c..0f86aaa0d7be8 100644 --- a/postgres/datadog_checks/postgres/relationsmanager.py +++ b/postgres/datadog_checks/postgres/relationsmanager.py @@ -160,6 +160,7 @@ current_database(), N.nspname, C.relname, + Inh.inhparent::regclass AS partition_of, pg_stat_get_numscans(C.oid), pg_stat_get_tuples_returned(C.oid), I.idx_scan, @@ -191,6 +192,7 @@ C.xmin FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) +LEFT JOIN pg_inherits Inh ON (Inh.inhrelid = C.oid) LEFT JOIN pg_locks L ON C.oid = L.relation AND L.locktype = 'relation' LEFT JOIN pg_index idx_toast ON (idx_toast.indrelid = C.reltoastrelid) LEFT JOIN LATERAL ( @@ -207,6 +209,7 @@ {'name': 'db', 'type': 'tag'}, {'name': 'schema', 'type': 'tag'}, {'name': 'table', 'type': 'tag'}, + {'name': 'partition_of', 'type': 'tag'}, {'name': 'seq_scans', 'type': 'rate'}, {'name': 'seq_rows_read', 'type': 'rate'}, {'name': 'index_rel_scans', 'type': 'rate'}, From 33c2a61dfff95f786a719c0f25644799e2b97aeb Mon Sep 17 00:00:00 2001 From: Christopher Anciaux Date: Tue, 24 Dec 2024 12:17:04 +0100 Subject: [PATCH 2/2] fix broken test --- postgres/datadog_checks/postgres/relationsmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/datadog_checks/postgres/relationsmanager.py b/postgres/datadog_checks/postgres/relationsmanager.py index 0f86aaa0d7be8..56444a7956636 100644 --- a/postgres/datadog_checks/postgres/relationsmanager.py +++ b/postgres/datadog_checks/postgres/relationsmanager.py @@ -209,7 +209,7 @@ {'name': 'db', 'type': 'tag'}, {'name': 'schema', 'type': 'tag'}, {'name': 'table', 'type': 'tag'}, - {'name': 'partition_of', 'type': 'tag'}, + {'name': 'partition_of', 'type': 'tag_not_null'}, {'name': 'seq_scans', 'type': 'rate'}, {'name': 'seq_rows_read', 'type': 'rate'}, {'name': 'index_rel_scans', 'type': 'rate'},