Skip to content

Instantly share code, notes, and snippets.

@doi-t
Created September 11, 2018 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doi-t/4debb3f9cb1c679ef30bcf82b5c592aa to your computer and use it in GitHub Desktop.
Save doi-t/4debb3f9cb1c679ef30bcf82b5c592aa to your computer and use it in GitHub Desktop.
View a stacked graph of an EC2 Per-Instance metric for EC2 instances that has prefix you specified.
# As of 2018/09/11
# METEIC can be either NetworkPacketsOut, NetworkPacketsIn, DiskReadOps, StatusCheckFailed, StatusCheckFailed_Instance, NetworkOut, NetworkIn, DiskWriteBytes, StatusCheckFailed_System, CPUUtilization, DiskWriteOps or DiskReadBytes
METRIC='NetworkIn'; REGION='ap-northeast-1'; NAME_TAG_VALUE='your_instance_name_prefix*'; echo "https://${REGION}.console.aws.amazon.com/cloudwatch/home?region=${REGION}#metricsV2:graph=~(view~'timeSeries~stacked~false~metrics~(`aws ec2 describe-instances --filter Name=tag:Name,Values="${NAME_TAG_VALUE}" | jq '.[][].Instances[].InstanceId' --raw-output | sed "s/^/~(~'AWS*2fEC2~'${METRIC}~'InstanceId~'/g" | sed "s/$/~(stat~'Sum))/g" | tr -d '\n'`)~view~'timeSeries~stacked~true~region~'${REGION})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment