Azure 서비스 리소스 로그 수집 점검

주요 Azure 서비스에서 필요한 리소스 로그를 수집하고 중앙 저장소로 전달하세요.

설명

Azure 서비스별로 요청과 장애를 조사하는 데 필요한 리소스 로그를 선택하세요. 구독 Activity Log는 관리 작업을 기록합니다.

잠재적 영향

요청 로그가 없으면 어떤 요청이 실패했는지 확인하거나 여러 서비스의 이벤트를 연결하기 어렵습니다.

해결 방법

기존 수집 경로를 확인하세요. 필요한 로그가 없다면 azurerm_monitor_diagnostic_setting에 지원되는 범주와 목적지(Log Analytics, 스토리지 또는 Event Hubs)를 지정하세요. 서비스의 로깅 설정, 목적지 권한과 보관 기간을 확인한 뒤 실제 요청을 보내 로그를 찾으세요.

예시

예제는 이전 azurerm_app_service 형식으로 AppServiceHTTPLogs만 스토리지에 보냅니다. 현재 AzureRM 버전에 맞는 웹앱 리소스와 필요한 다른 로그 범주를 선택하세요.

변경 전

hcl
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
}

변경 후

hcl
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"
  }
}

참조