cloud/azure

azure log analytics 또는 log 에서 로그 확인 SQL

세모데 2022. 6. 15. 17:47

1. WAF에서 특정 로그 생성 여부 확인

 

AzureDiagnostics
| where Category == "ApplicationGatewayFirewallLog"
| where hostname_s  == "test.testcom.com"
| where action_s == "Matched" or action_s == "Blocked"
| sort by TimeGenerated

 

2. CDN에서 정보 조회

AzureDiagnostics 
| sort by TimeGenerated   
| project format_datetime(datetime_add('hour', 9, TimeGenerated), 'yyyyMMddHHmm'), Category, clientIp_s, requestUri_s, cacheStatus_s

 

-- sort by  TimeGenerated   : 시간순으로 정렬

-- project   컬럼들 : 컬럼들을 가지고 와서 가공 처리하여 표시

-- format_datetime : 시간을 다른 형식으로 표시

-- datetime_add : UTC 에 +9를 추가하여 표시

 

 

AzureDiagnostics | distinct clientIp_s, requestUri_s, cacheStatus_s

-- distinct  컬럼들 : 해당 컬럼들에 unique 한 값을 가지고 와서 표시

 

let cutoff = ago(24h);    -- 변수를 지정 (시간전 시간 지정)

AzureDiagnostics
| where TimeGenerated > cutoff       -- 변수를 사용하여 쿼리 진행
| where cacheStatus_s == "MISS"
| where Category == "AzureCdnAccessLog"
| summarize count() by format_datetime(TimeGenerated, 'yyyy-MM-dd hh');

 

AzureDiagnostics | take 10        -- 10개 row만 가져 오기

AzureDiagnostics | 

 

 

Kusto참고 페이지 :  https://docs.microsoft.com/ko-kr/azure/data-explorer/kusto/query/best-practices