The log_retention server parameter in Azure PostgreSQL determines whether database logs are retained, which is essential for auditing and troubleshooting purposes. If this parameter is set to OFF, as shown below, log data will not be persisted, potentially hindering investigations into security incidents or operational issues:
resource "azurerm_postgresql_configuration" "example" {
name = "log_retention"
resource_group_name = data.azurerm_resource_group.example.name
server_name = azurerm_postgresql_server.example.name
value = "OFF"
}
To address this, ensure that log_retention is set to ON, as in the configuration below, so that important logs are retained and available for review:
resource "azurerm_postgresql_configuration" "example" {
name = "log_retention"
resource_group_name = data.azurerm_resource_group.example.name
server_name = azurerm_postgresql_server.example.name
value = "ON"
}
Failing to enable log retention can result in loss of critical data needed for compliance, monitoring, and incident response.