Skip to content

Instantly share code, notes, and snippets.

@mpyw
Created September 8, 2018 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpyw/2af3378070445c651e8cfb91d6dadd20 to your computer and use it in GitHub Desktop.
Save mpyw/2af3378070445c651e8cfb91d6dadd20 to your computer and use it in GitHub Desktop.
古いログストリームを削除
#!/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