LoginSignup
0
1

More than 1 year has passed since last update.

【CloudWatch Logs Insight】サンプルクエリ

Last updated at Posted at 2021-05-10

2xx 系のメッセージログを抽出する

fields @message
| filter (status < 300)
| display @message
| limit 10

特定の送信元 IP アドレス以外の 送信元 IP アドレスごとのリクエスト数をカウントする

fields @message
| filter ip not in ["<除外したい IP アドレス1>", "<除外したい IP アドレス2>", ...]
| stats count(*) as count by ip
| sort count desc
| limit 10

送信元 IP アドレス, リクエストメソッド, リクエストURI ごとのリクエスト数をカウントする

fields @message
| stats count(*) as count by ip, httpMethod, resourcePath, status
| sort count desc
| limit 10

上記のサンプルの参考サイト

送信元 IP ごとにカウント

fields @message
| filter @logStream =~ /<ログストリーム名>/
| parse @message '* * * [*] "* * *" * "*" "*"' as srcIpAddress, srcUser, remoteUser, timestamp, httpMethod, requestUri, protocol, statusCode, transferredData, referer, userAgent
| filter requestUri = "/"
| filter statusCode =~ /2\d\d/
| stats count(*) as count by srcIpAddress
| sort count desc
| limit 10

parseコマンドの参考サイト

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1