Description
Choose the Azure resource logs you need to investigate requests and failures. The subscription Activity Log records management operations.
Potential impact
Missing request logs make it harder to identify a failed request or trace it across services.
Remediation
Check existing collection first. In azurerm_monitor_diagnostic_setting, select the missing categories supported by the resource and a destination such as Log Analytics, Storage or Event Hubs. Check service logging settings, destination permissions and retention. Send a request and find its log at the destination.
Examples
The example uses the older azurerm_app_service resource and exports only AppServiceHTTPLogs to storage. Choose the web app resource supported by your AzureRM version and any other categories you need.
Before
resource "azurerm_app_service" "example" {
name = "example-app-service"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
}
After
resource "azurerm_app_service" "example" {
name = "example-app-service"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
}
resource "azurerm_monitor_diagnostic_setting" "example" {
name = "app-service-diagnostics"
target_resource_id = azurerm_app_service.example.id
storage_account_id = azurerm_storage_account.example.id
enabled_log {
category = "AppServiceHTTPLogs"
}
}