Skip to content

Instantly share code, notes, and snippets.

@jlongman
Created April 15, 2023 15:55
Show Gist options
  • Save jlongman/c6234a9041fa9e142685c215a274f4b6 to your computer and use it in GitHub Desktop.
Save jlongman/c6234a9041fa9e142685c215a274f4b6 to your computer and use it in GitHub Desktop.
One element path 404s in apache log with cloudwatch log insights
fields @timestamp, @message
| parse @message /^(?<local>\S+) (?<remoteA>\S+)(, (?<remoteB>\S+))? - - \[(?<date>[\w:\+\/ -]*?)\] "(?<method>[A-Za-z-]+) (?<path>[\/\w_-]+) (?<protocol>[\/\w0-9\.-]+)" (?<status>[0-9-]+) (?<bytes>[0-9-]*) "(?<url>\S*?)" "(?<web>.*)"$/
| filter path like /^\/\S+\/?$/ and status like /404/
| stats count(*) as hits by path
| sort hits desc
@jlongman
Copy link
Author

I ended up having a minor typo which had me crawling all over the regex changing things, so maybe needs cleaning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment