I had to troubleshoot one application at AWS and was not easy to use all CloudWatch Metrics Graphs to interpret environment healthiness, so I decided to share my experience here.
CloudWatch give us metrics for CPU, Memory*, Disk and Network.
* to get memory metrics you need to install CloudWatch Agent.
CPU and Memory give us the metric in percentage, which is clear ans strait-forward to interpret. But Disk and Network are not that easy, for example I would like to check IOPS and Throughput (MiB/s) for my volumes and Network (Gbps).
I needed those values because AWS define EBS limits as IOPS and Throughput (MB/s) and Instance network limit as Gbps.
Total IOPS
EBS Volume give us metrics
VolumeReadOps
andVolumeWriteOps
. Let me quote AWS documentation.Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cloudwatch_ebs.html
To get the Total IOPS we need to
(VolumeReadOps + VolumeWriteOps) / SecondsInPeriod
.Luckily CloudWatch help us with
Expression
. Use the expression below, the functionPERIOD
is our friend here.Reference: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html
Total Throughput (MiB/s)
EBS Volume give us metrics
VolumeReadBytes
andVolumeWriteBytes
. Let me quote AWS documentation.Both metrics give us the value in
bytes
, but we want them inMiB
, so to convert we need to divide by1048576
, which is the result of1024 * 1024
. Let me explain in detail.To get the Total Throughput in
MiB/s
we need to((VolumeReadBytes + VolumeWriteBytes) / 1048576) / SecondsInPeriod
.Use the expression below, the function
PERIOD
is our friend here.Total Network (Gbps)
EC2 Instance give us metrics
NetworkIn
andNetworkOut
. Let me quote AWS documentation.Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html
Both metrics give us the value in
bytes per period
, but we want them ingigabits / second
.To convert from "period" to "second" we just need to divide by
300
(as I am using standard monitoring).To convert from
bytes
togigabits
we need to divide and multiply as(1000 / 1000 / 1000) * 8
. Let me explain in detail.To get Total Network in
Gbps
we need to((NetworkIn + NetworkOut) / 300) / 0.008
.