Description
Enable log_disconnections on PostgreSQL Servers.
NOTE: This recommendation currently only applies to Single Server, not Flexible Server. See additional information below for details about the planned retirement of Azure PostgreSQL Single Server.
Rationaleβ
Enabling log_disconnections helps PostgreSQL log the end of a session, including duration, which in turn generates query and error logs. Query and error logs can be used to identify, troubleshoot, and repair configuration errors and suboptimal performance.
Impactβ
Enabling this setting logs all disconnections. If this is enabled for a high-traffic server, the log may grow quickly.
Auditβ
From Azure Portalβ
- From Azure Home, select the Portal Menu.
- Go to
Azure DatabaseforPostgreSQL servers. - For each database, under
Settings, clickServer parameters. - Search for
log_disconnections. - Ensure that
log_disconnectionsis set toON.
From Azure CLIβ
Ensure log_disconnections is set to ON:
az postgres server configuration show \
--resource-group {{resource-group-name}} \
--server-name {{server-name}} \
--name log_disconnections
From PowerShellβ
Ensure log_disconnections is set to ON:
Get-AzPostgreSqlConfiguration `
-ResourceGroupName {{resource-group-name}} `
-ServerName {{server-name}} `
-Name log_disconnections
From Azure Policyβ
If referencing a digital copy of this Benchmark, clicking a Policy ID will open a link to the associated Policy definition in Azure.
- Policy ID: eb6f77b9-bd53-4e35-a23d-7f65d5f0e446 - Name:
Disconnections should be logged for PostgreSQL database servers
Default Valueβ
By default, log_disconnections is disabled (set to off).
Referencesβ
- https://docs.microsoft.com/en-us/rest/api/postgresql/singleserver/configurations/list-by-server
- https://docs.microsoft.com/en-us/azure/postgresql/howto-configure-server-parameters-using-portal
- https://learn.microsoft.com/en-us/security/benchmark/azure/mcsb-logging-threat-detection#lt-3-enable-logging-for-security-investigation
- https://learn.microsoft.com/en-us/powershell/module/az.postgresql/get-azpostgresqlconfiguration?view=azps-9.2.0#example-2-get-specified-postgresql-configuration-by-name
- https://learn.microsoft.com/en-us/powershell/module/az.postgresql/update-azpostgresqlconfiguration?view=azps-9.2.0#example-1-update-postgresql-configuration-by-name
Additional Informationβ
RETIREMENT of Azure PostgreSQL Single Server: Azure PostgreSQL Single Server is slated for retirement by March 25, 2025. Please use these resources to consider and prepare for migration: