Created
September 8, 2018 12:03
-
-
Save mpyw/2af3378070445c651e8cfb91d6dadd20 to your computer and use it in GitHub Desktop.
古いログストリームを削除
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
#!/bin/bash | |
for group in $(aws logs describe-log-groups | jq -r '.logGroups[].logGroupName'); do | |
echo "Fetching: $group" | |
for stream in $(aws logs describe-log-streams --log-group-name "$group" | jq -r ' | |
.logStreams[] | |
| select(.storedBytes == 0 and ($now|tonumber) - .creationTime / 1000 > 86400) | |
| .logStreamName | |
' --arg now $(date +%s)); do | |
echo "Deleting: $group $stream" | |
aws logs delete-log-stream --log-group-name "$group" --log-stream-name "$stream" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment