Last active
July 5, 2018 20:26
-
-
Save ajohnstone/98be334bec73ff4da11fed4d2e186a73 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
START="$(date +'%Y-%m-%dT%H:%M:%S' --date '-5 minutes')"; | |
END="$(date +'%Y-%m-%dT%H:%M:%S')"; | |
aws elb describe-load-balancers | jq -r '.LoadBalancerDescriptions[].LoadBalancerName' | while read LB; do | |
DATA=$(aws cloudwatch get-metric-statistics \ | |
--namespace AWS/ELB \ | |
--metric-name "RequestCount" \ | |
--dimensions '[{"Name":"LoadBalancerName","Value":"'$LB'"}]' \ | |
--start-time "$START" \ | |
--end-time "$END" \ | |
--period 60 \ | |
--statistics Sum); | |
TAGS=$(aws elb describe-tags --load-balancer-names="$LB" | jq -r '.TagDescriptions[0].Tags[]') | |
REQUEST_COUNT=$(echo "${DATA}"| jq -r '[.Datapoints[] | .Sum] | (max|@json)'); | |
echo $LB - $REQUEST_COUNT - $TAGS; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment