Sentryへの通知があったあたりのログをcloudwatchから取得する
ソース
※awslogsが4/11/2020 04:50の形式で検索が上手く行かない。
function detecte_log { EXPAND_SECONDS=10 if [ "$#" -ne 1 ]; then echo "Need time such as 'July 29 2020 17:24:07 JST'" exit 1 fi occured_time=$1 start_time=`date +"%d/%m/%Y %T" --utc -d "$occured_time -${EXPAND_SECONDS}seconds"` end_time=`date +"%d/%m/%Y %T" --utc -d "$occured_time +${EXPAND_SECONDS}seconds"` echo "$start_time ~ $end_time" echo "detecting..." output_log=/path/to/filename.$(date +%s).log awslogs get -G -S /group_name stream_name/* --start="$start_time" --end="$end_time" > $output_log echo "check: $output_log" } Usage
$ detecte_log "July 29 2020 17:24:07 JST" This post is licensed under CC BY 4.0 by the author.