Other Articles

PostgreSQL Flexible Server – Enable Disconnection Logging

This check ensures that the log_disconnections server parameter is enabled for Azure Database for PostgreSQL Flexible Servers. Enabling disconnection logging allows administrators to monitor client session terminations and improves auditing, troubleshooting, and security visibility.

Check Details

  • Resource: Azure Database for PostgreSQL Flexible Server
  • Check: Ensure log_disconnections Parameter Is Enabled
  • Risk: If disconnection logging is disabled, unexpected session terminations or suspicious client behavior may go undetected, reducing the organization’s ability to investigate security incidents or performance issues.

Remediation via Azure Portal

  1. Log in to the Azure Portal. Azure Portal dashboard
  2. Navigate to Azure Database for PostgreSQL Flexible Servers and select the affected server. PostgreSQL Flexible Servers list
  3. Under Settings, select Server parameters. PostgreSQL server parameters
  4. Search for the parameter log_disconnections.
  5. Ensure the value is set to ON. PostgreSQL server log disconnections
  6. Click Save to apply the configuration.

Remediation via Azure CLI

  1. Open Azure Cloud Shell or a local terminal with Azure CLI installed. Azure Cloud Shell
  2. Check the current value of the log_disconnections parameter:

    az postgres flexible-server parameter show \
     --resource-group <resource-group> \
     --server-name <server-name> \
     --name log_disconnections
    
  3. Enable disconnection logging if it is disabled:

    az postgres flexible-server parameter set \
     --resource-group <resource-group> \
     --server-name <server-name> \
     --name log_disconnections \
     --value on
    
  4. Verify the parameter has been updated:

    az postgres flexible-server parameter show \
     --resource-group <resource-group> \
     --server-name <server-name> \
     --name log_disconnections \
     --query value
    

Replace <resource-group> and <server-name> with your actual values. The output should confirm that the parameter value is set to on.