Created
February 21, 2021 03:38
-
-
Save potaracom/dac2cedf29c268afaa34933a12697aec to your computer and use it in GitHub Desktop.
CloudWatch Logsのtail -f
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/bash | |
prompt="ロググループ名を選択してください:" | |
options=$(aws logs describe-log-groups | jq -r ".logGroups[] | select( .logGroupName | contains(\"$1\")) | .logGroupName") | |
if [[ $options == "" ]]; then | |
echo "ロググループが存在しませんでした。" | |
exit 0 | |
fi | |
count=$(echo "$options" | wc -l) | |
if (( $count == 1 )); then | |
echo aws logs tail --follow $options | |
aws logs tail --follow $options | |
exit 0 | |
fi | |
PS3="$prompt " | |
select option in ${options[@]} "Quit" ; do | |
if [[ $option == "Quit" ]]; then | |
echo "終了します。" | |
exit 0 | |
elif [[ $option == "" ]]; then | |
echo "選択肢ではない値が入力されました。再度入力してください。" | |
else | |
break | |
fi | |
done | |
echo "log($option)のウォッチを開始します。" | |
aws logs tail --follow $option | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment