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
Azure Resource Manager¶
Ensure that a Microsoft.DBforPostgreSQL/servers/configurations resource contains the following, where
value
is set to4
or greater:
{
"name": "log_retention_days",
"properties": {
"value": "4"
}
}
Example Configuration¶
{
"type": "Microsoft.DBforPostgreSQL/servers/configurations",
"apiVersion": "2017-12-01",
"name": "log_retention_days",
"properties": {
"value": "4"
}
# other required fields here
}
Terraform¶
Ensure that an azurerm_postgresql_configuration contains the following:
name
= “log_retention_days”value
>= 4
Example Configuration¶
resource "azurerm_postgresql_configuration" "example" {
name = "log_retention_days"
value = 4
# other required fields here
}