Skip to content

Instantly share code, notes, and snippets.

@jhmartin
Last active July 5, 2018 20:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhmartin/d3f72246881a07c3d7efe0e14e8fd3c0 to your computer and use it in GitHub Desktop.
Save jhmartin/d3f72246881a07c3d7efe0e14e8fd3c0 to your computer and use it in GitHub Desktop.
Pull recent CW stats for pasting
#!/bin/sh
# Fetch 2-3 minutes in the past as current data isnt there yet
NOWDATE=$(date -v-2M -u +"%Y-%m-%dT%H:%M:%SZ")
LASTDATE=$(date -v-3M -u +"%Y-%m-%dT%H:%M:%SZ")
date
#-start-time 2014-04-08T23:18:00Z --end-time 2014-04-09T23:18:00Z --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-abcdef
export AWS_PROFILE=jmtdlcw
UTILSLATENCY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name Latency --period 60 --namespace AWS/ELB --statistic Average --dimensions Name=LoadBalancerName,Value=abc-prod-utilsapi|jq .Datapoints[0].Average)
UTILSVELOCITY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name RequestCount --period 60 --namespace AWS/ELB --statistic Sum --dimensions Name=LoadBalancerName,Value=abc-prod-utilsapi|jq .Datapoints[0].Sum)
echo Todayland Utils Velocity: $UTILSVELOCITY rpm
echo Todayland Utils Latency: $UTILSLATENCY s
echo
PRESLATENCY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name Latency --period 60 --namespace AWS/ELB --statistic Average --dimensions Name=LoadBalancerName,Value=abc-prod-pres-api|jq .Datapoints[0].Average)
PRESVELOCITY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name RequestCount --period 60 --namespace AWS/ELB --statistic Sum --dimensions Name=LoadBalancerName,Value=abc-prod-pres-api|jq .Datapoints[0].Sum)
echo Todayland Pres Velocity: $PRESVELOCITY rpm
echo Todayland Pres Latency: $PRESLATENCY s
echo
export AWS_PROFILE=jmtmlcw
GKEASTLATENCY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name TargetResponseTime --period 60 --namespace AWS/ApplicationELB --statistic Average --dimensions Name=LoadBalancer,Value=app/Gatekee-alb-TNX0BMXTKT7T/b3a1446bd0609fd0|jq .Datapoints[0].Average)
GKEASTVELOCITY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name RequestCount --period 60 --namespace AWS/ApplicationELB --statistic Sum --dimensions Name=LoadBalancer,Value=app/Gatekee-alb-TNX0BMXTKT7T/b3a1446bd0609fd0|jq .Datapoints[0].Sum)
echo Tomorrowland East Velocity: $GKEASTVELOCITY rpm
echo Tomorrowland East Latency: $GKEASTLATENCY s
echo
export AWS_DEFAULT_REGION=us-west-2
GKWESTLATENCY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name TargetResponseTime --period 60 --namespace AWS/ApplicationELB --statistic Average --dimensions Name=LoadBalancer,Value=app/Gatekee-alb-15UD2X5GFI4SZ/7fff6f77a1f8615e|jq .Datapoints[0].Average)
GKWESTVELOCITY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name RequestCount --period 60 --namespace AWS/ApplicationELB --statistic Sum --dimensions Name=LoadBalancer,Value=app/Gatekee-alb-15UD2X5GFI4SZ/7fff6f77a1f8615e|jq .Datapoints[0].Sum)
echo Tomorrowland West Velocity: $GKWESTVELOCITY rpm
echo Tomorrowland West Latency: $GKWESTLATENCY s
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment