PostgreSQL Database configuration ‘log_connections’ should be on

Description

Enabling log_connections helps PostgreSQL Database to log attempted connections to the server, as well as successful completion of client authentication. Log data can be used to identify, troubleshoot, and repair configuration errors and suboptimal performance.

Remediation Steps

Azure Portal

Azure CLI

  • To enable log_connections:

az postgres server configuration set --resource-group <resourceGroupName> --server-name <serverName> --name log_connections --value on

Azure Resource Manager

{
  "name": "log_connections",
  "properties": {
    "value": "on"
  }
}

Example Configuration

{
  "type": "Microsoft.DBforPostgreSQL/servers/configurations",
  "apiVersion": "2017-12-01",
  "name": "log_connections",
  "properties": {
    "value": "on"
  }
  # other required fields here
}

Terraform

Example Configuration

resource "azurerm_postgresql_configuration" "example" {
  name  = "log_connections"
  value = "on"

  # other required fields here
}