PostgreSQL Database configuration ‘log_duration’ should be on

Description

Enabling log_duration helps the PostgreSQL Database to Logs the duration of each completed SQL statement 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.

Remediation Steps

Azure Portal

Azure CLI

  • To enable log_duration:

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

Azure Resource Manager

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

Example Configuration

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

Terraform

Example Configuration

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

  # other required fields here
}