I wanted to find out what each unit was in CloudWatch Metrics, but I didn't have a good list, so I made one.
bash
+ ʻaws-cli seems to be annoying, so it seems that you can make it quickly with
Ruby, but if you study, with
Python`.
#!/usr/bin/env python
import sys
import datetime
import re
from boto.ec2 import cloudwatch
end = datetime.datetime.utcnow()
start = end - datetime.timedelta(minutes=10)
cw = cloudwatch.connect_to_region('ap-northeast-1')
def main():
if len(sys.argv) not in [2,3]:
print('Usage: python %s <namespace> [separator]' % sys.argv[0])
quit()
namespace = sys.argv[1]
separator = "\t" if len(sys.argv) == 2 else sys.argv[2]
results = []
for metric in cw.list_metrics(namespace=namespace):
for data in metric.query(start_time=start, end_time=end, statistics='Average'):
results.append(separator.join([namespace, metric.name, data['Unit']]))
results = list(set(results))
for ret in results:
print(ret)
if __name__ == '__main__':
main()
python <script-file-name> <namespace> [separator]
If separator
is not specified, it will be tab-delimited.
For those who don't know if they are there, but just want to know the results. (EC2, EBS, RDS only)
$ python get-metrics-unit-type.py AWS/EC2
AWS/EC2 CPUCreditUsage Count
AWS/EC2 CPUCreditBalance Count
AWS/EC2 StatusCheckFailed Count
AWS/EC2 DiskReadOps Count
AWS/EC2 StatusCheckFailed_System Count
AWS/EC2 DiskWriteBytes Bytes
AWS/EC2 NetworkOut Bytes
AWS/EC2 DiskReadBytes Bytes
AWS/EC2 NetworkIn Bytes
AWS/EC2 DiskWriteOps Count
AWS/EC2 StatusCheckFailed_Instance Count
AWS/EC2 CPUUtilization Percent
$ python get-metrics-unit-type.py AWS/EBS
AWS/EBS VolumeWriteBytes Bytes
AWS/EBS VolumeQueueLength Count
AWS/EBS VolumeReadOps Count
AWS/EBS VolumeIdleTime Seconds
AWS/EBS VolumeTotalWriteTime Seconds
AWS/EBS VolumeWriteOps Count
$ python get-metrics-unit-type.py AWS/RDS
AWS/RDS FreeableMemory Bytes
AWS/RDS NetworkTransmitThroughput Bytes/Second
AWS/RDS DatabaseConnections Count
AWS/RDS WriteIOPS Count/Second
AWS/RDS ReadIOPS Count/Second
AWS/RDS ReadLatency Seconds
AWS/RDS WriteThroughput Bytes/Second
AWS/RDS ReadThroughput Bytes/Second
AWS/RDS FreeStorageSpace Bytes
AWS/RDS WriteLatency Seconds
AWS/RDS DiskQueueDepth Count
AWS/RDS CPUUtilization Percent
AWS/RDS CPUCreditUsage Count
AWS/RDS NetworkReceiveThroughput Bytes/Second
AWS/RDS CPUCreditBalance Count
AWS/RDS BinLogDiskUsage Bytes
AWS/RDS SwapUsage Bytes
――At first, it wasn't official but made by the community (isn't it?), So I feel that the usability is a little different from other SDKs. ――On the contrary, it seems to be practically important, so if you get used to it, it may be easier to use than others.
Recommended Posts