Skip to content

Instantly share code, notes, and snippets.

@brunocasarotti
Created October 11, 2022 19:06
Show Gist options
  • Save brunocasarotti/6f60d3900c99c118b7a049a8b55883a5 to your computer and use it in GitHub Desktop.
Save brunocasarotti/6f60d3900c99c118b7a049a8b55883a5 to your computer and use it in GitHub Desktop.
Monitor number of messages in SQS queues using AWS CLI bash script
#!/bin/bash
queues=(
"queue-1"
"queue-2"
)
for i in "${queues[@]}"
do
aws --profile MY-PROFILE sqs get-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/00000000000000000/$i --attribute-names ApproximateNumberOfMessages \
| grep ApproximateNumberOfMessage \
| tr -d \" \
| awk -v queuename=$i -F: '{print queuename $2}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment