postgres find out out the successful connection via Azure Logs
To uncover the connection being used in a postgres server and historical data, we can use the following query to uncover who is connected, the user and which database.
This handle query is illustrated here - notice that we are pulling out information of a specific point in time.
AzureDiagnostics
| where Category == "PostgreSQLLogs"
| where TimeGenerated between (datetime(2026-04-23 15:02:00) .. datetime(2026-04-23 15:09:00))
| where Message contains "connection authorized"
| extend DbUser = extract(@"user=([^\s]+)", 1, Message)
| extend DbName = extract(@"database=([^\s]+)", 1, Message)
| summarize ConnectionCount = count() by DbUser, DbName
| order by ConnectionCount desc
Comments