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 Database to Logs 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 sub-optimal performance.
Impactβ
Enabling this setting will enable a log of all disconnections. If this is enabled for a high traffic server, the log may grow exponentially.
Auditβ
From Azure Portalβ
- From Azure Home select the Portal Menu.
- Go to
Azure Database
forPostgreSQL servers
. - For each database, under
Settings
, clickServer parameters
. - Search for
log_disconnections
. - Ensure that
log_disconnections
is set toON
.
From Azure CLIβ
Ensure log_disconnections
value is set to ON
:
az postgres server configuration show --resource-group <resourceGroupName> --server-name <serverName> --name log_disconnections
From PowerShellβ
Ensure log_disconnections
value is set to ON
:
Get-AzPostgreSqlConfiguration -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -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: