Created
May 29, 2017 05:04
-
-
Save campezzi/4dfee33648aa09adde97ce88e879655b to your computer and use it in GitHub Desktop.
Search for lambda logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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