From 9ff47f00fbe8140a163941bbc8590c0942ec4885 Mon Sep 17 00:00:00 2001 From: jdmsoss <174804059+jdmsoss@users.noreply.github.com> Date: Wed, 9 Oct 2024 00:44:15 +0200 Subject: [PATCH] fix: arg code for PostgreSQL read replica detection (#430) --- .../kql/2ab85a67-26be-4ed2-a0bb-101b2513ec63.kql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/azure-resources/DBforPostgreSQL/flexibleServers/kql/2ab85a67-26be-4ed2-a0bb-101b2513ec63.kql b/azure-resources/DBforPostgreSQL/flexibleServers/kql/2ab85a67-26be-4ed2-a0bb-101b2513ec63.kql index 958d98acf..237d4c9fa 100644 --- a/azure-resources/DBforPostgreSQL/flexibleServers/kql/2ab85a67-26be-4ed2-a0bb-101b2513ec63.kql +++ b/azure-resources/DBforPostgreSQL/flexibleServers/kql/2ab85a67-26be-4ed2-a0bb-101b2513ec63.kql @@ -1,6 +1,8 @@ // Azure Resource Graph Query -// Find Database for PostgreSQL instances that are read replicas +// Find Database for PostgreSQL instances that do not have read replicas resources -| where type == "microsoft.dbforpostgresql/flexibleservers" -| where properties.replicationRole == "AsyncReplica" -| project recommendationId = "2ab85a67-26be-4ed2-a0bb-101b2513ec63", name, id, tags, param1 = strcat("replicationRole:", properties['replicationRole']) +| where type == "microsoft.dbforpostgresql/flexibleservers" and properties.replicationRole == "AsyncReplica" +| project replicaServerId = id, id = tostring(properties.sourceServerResourceId) +| join kind=fullouter (resources | where type == "microsoft.dbforpostgresql/flexibleservers" and properties.replicationRole != "AsyncReplica") on id +| where isempty(replicaServerId) +| project recommendationId = "2ab85a67-26be-4ed2-a0bb-101b2513ec63", name, id = id1, tags, param1 = strcat("replicationRole:", properties['replicationRole'])