Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yicr/d1d406cc53b0aefe912042321918faf5 to your computer and use it in GitHub Desktop.
Save yicr/d1d406cc53b0aefe912042321918faf5 to your computer and use it in GitHub Desktop.

AWS : CloudWatch Logs Insight / Parse Count Http Status Code from Apache Log.

Parse & count http code 2xx

ログをパースしてステータスコードが2XXなログをカウントする。

parse '* - * [*] "* * *" * * * *' as host, identity, dateTimeString, httpVerb, url, protocol, statusCode, bytes, Referer, UserAgent
| sort dateTimeString desc
| filter statusCode like /(2\d\d)/
| count()

期間を指定する

list http code 2xx

parse '* - * [*] "* * *" * * * *' as host, identity, dateTimeString, httpVerb, url, protocol, statusCode, bytes, Referer, UserAgent
| sort dateTimeString desc
| filter statusCode like /(2\d\d)/
parse '* - * [*] "* * *" * * "*" "*" "*"' as host, identity, dateTimeString, httpVerb, url, protocol, statusCode, bytes, Referer, UserAgent, ClientIp

urlでユニークカウント

parse '* - * [*] "* * *" * * "*" "*" "*"' as host, identity, dateTimeString, httpVerb, url, protocol, statusCode, bytes, Referer, UserAgent, ClientIp
| sort dateTimeString desc
| filter statusCode like /(4\d\d)/
| count() as count by url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment