Skip to content

Instantly share code, notes, and snippets.

@ajohnstone
Last active July 5, 2018 20:26
Show Gist options
  • Save ajohnstone/98be334bec73ff4da11fed4d2e186a73 to your computer and use it in GitHub Desktop.
Save ajohnstone/98be334bec73ff4da11fed4d2e186a73 to your computer and use it in GitHub Desktop.
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