PostgreSQL Database configuration ‘log_retention days’ should be greater than 3

Description

Enabling log_retention_days helps PostgreSQL Database to Sets number of days a log file is retained 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

  • Navigate to Azure Database for PostgreSQL servers.

  • Select the PostgreSQL server.

  • In the left navigation, select Server parameters.

  • In log_retention_days, set the retention period to be greater than 3 days.

  • Click Save.

Azure CLI

  • To enable log_retention_days greater than 3:

az postgres server configuration set --resource-group <resourceGroupName> --server-name <serverName> --name log_retention_days --value 4

Terraform

Example Configuration

resource "azurerm_postgresql_configuration" "example" {
  name  = "log_retention_days"
  value = 4

  # other required fields here
}