Description
On Flexible Server, log_disconnections records each session’s end time and duration.
Potential impact
Without an end record, it is harder to investigate repeated reconnects or a session that closed early. Connection and error records from the same time can help explain the cause.
Remediation
Set log_disconnections to on. Open and close a new test connection, then find its end time and duration at the log destination. Enable connection logs if needed for comparison. Set retention for the investigation period and restrict who can read the records.
Examples
The first resource targets retired Single Server. The second applies the parameter to the existing Flexible Server identified by server_id.
Before
hcl
resource "azurerm_postgresql_configuration" "example" {
name = "log_disconnections"
resource_group_name = data.azurerm_resource_group.example.name
server_name = azurerm_postgresql_server.example.name
value = "OFF"
}
After
hcl
resource "azurerm_postgresql_flexible_server_configuration" "example" {
name = "log_disconnections"
server_id = azurerm_postgresql_flexible_server.example.id
value = "on"
}