Skip to content

Instantly share code, notes, and snippets.

@campezzi
Created May 29, 2017 05:04
Show Gist options
  • Save campezzi/4dfee33648aa09adde97ce88e879655b to your computer and use it in GitHub Desktop.
Save campezzi/4dfee33648aa09adde97ce88e879655b to your computer and use it in GitHub Desktop.
Search for lambda logs
#!/usr/bin/env bash
function get_events() {
echo "Fetching logs for $1 lambda in the $2 region (since $3)..."
aws logs filter-log-events --log-group-name "/aws/lambda/$1" --region "$2" --start-time "$3" --filter-pattern requestId | jq '.events'
}
case $1 in
"all")
get_events $2 ${3:-us-west-2} ${4:-1496030995836}
;;
"count")
get_events $2 ${3:-us-west-2} ${4:-1496030995836} | grep -Eo "requestId: '[0-9a-f-]+'" | uniq -c
;;
*)
echo "Usage: 'search all lambda-name [region] [start-time]' or 'search count lambda-name [region] [start-time]'"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment