Last active
January 4, 2022 18:41
-
-
Save ford-prefect/722b23c7f2b7cb8ca676e8803d509039 to your computer and use it in GitHub Desktop.
CloudWatch downloader
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 | |
set -e | |
N_PAGES=${N_PAGES:-100} | |
AWS_REGION=${AWS_REGION:-us-west-2} | |
next= | |
for i in $(seq 1 "${N_PAGES}"); do | |
echo "$i" | |
data=$(aws logs get-log-events --region="${AWS_REGION}" --log-group-name="/ecs/${LOG_GROUP}" --log-stream-name="${LOG_STREAM}" --start-time="${START_TIME}000" --start-from-head "${next}") | |
token=$(echo "$data" | jq -r ".nextForwardToken") | |
next="--next-token=${token}" | |
echo "${next}" | |
echo "${data}" >> "${1}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment