WAFのログをCloudWatch Log Insightsで検索するためのクエリサンプル集
ルール指定でブロックされたログ
fields @timestamp, @message
| filter action = "BLOCK"
| filter terminatingRuleId = "AWSManagedRulesSQLiRuleSet"
| sort @timestamp desc
| limit 20
ブロックされた理由まで表示する
fields @timestamp, @message, terminatingRuleId, ruleGroupList.0.terminatingRule.ruleId
| filter action = "BLOCK"
| filter terminatingRuleId != "OwnRulesIpLimit"
| sort @timestamp desc
| limit 20
リクエスト毎のブロックされた件数
stats count(*) by httpRequest.uri, terminatingRuleId, terminatingRuleType
| filter action = "BLOCK"
| sort @timestamp desc
| limit 20
許可されたリクエスト
fields @timestamp, @message
| filter action = "ALLOW"
| filter httpRequest.country = "JP"
| filter httpRequest.clientIp = "152.165.126.58"
| sort @timestamp desc
| limit 20
クライアントIP等指定でログを検索
fields @timestamp, @message
| filter httpRequest.country = "JP"
| filter httpRequest.clientIp = "1xx.1xx.1xx.xx"
| filter httpRequest.headers.0.value = "www.hogehoge.com"
| sort @timestamp desc
| limit 20