Description
Ensure logfiles.retention_days
on PostgreSQL flexible servers
is set to an appropriate value.
Rationaleβ
Configuring logfiles.retention_days
determines the duration in days that Azure Database for PostgreSQL
retains log files. Query and error logs can be used to identify, troubleshoot, and repair configuration errors and sub-optimal performance.
Impactβ
Configuring this setting will result in logs being retained for the specified number of days. If this is configured on a high traffic server, the log may grow quickly to occupy a large amount of disk space. In this case you may want to set this to a lower number.
Auditβ
From Azure Portalβ
- From Azure Home select the Portal Menu.
- Go to
Azure Database for PostgreSQL flexible servers
. - For each database, under
Settings
, clickServer parameters
. - In the filter bar, type
logfiles.retention_days
. - Ensure that the
VALUE
is between 4 and 7 (inclusive).
From Azure CLIβ
Ensure logfiles.retention_days
value is greater than 3:
az postgres flexible-server parameter show --resource-group <resourceGroup> --server-name <serverName> --name logfiles.retention_days
From Powershellβ
Ensure logfiles.retention_days
value is greater than 3:
Get-AzPostgreSqlFlexibleServerConfiguration -ResourceGroupName <resourceGroup> -ServerName <serverName> -Name logfiles.retention_days
Default Valueβ
By default logfiles.retention_days
is set to 3
.
Referencesβ
- https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-configure-server-parameters-using-portal
- https://learn.microsoft.com/en-us/rest/api/postgresql/flexibleserver/configurations/list-by-server
- https://learn.microsoft.com/en-us/security/benchmark/azure/mcsb-logging-threat-detection#lt-6-configure-log-storage-retention
- https://learn.microsoft.com/en-us/powershell/module/az.postgresql/get-azpostgresqlflexibleserverconfiguration?view=azps-12.2.0#example-1-get-specified-postgresql-configuration-by-name
- https://learn.microsoft.com/en-us/powershell/module/az.postgresql/update-azpostgresqlflexibleserverconfiguration?view=azps-12.2.0#example-1-updatae-specified-postgresql-configuration-by-name