gpt4 book ai didi

amazon-web-services - 卷 IOPS、卷吞吐量 (MiB/s) 和网络 (Gbps) 的 CloudWatch 指标

转载 作者:行者123 更新时间:2023-12-05 09:10:48 25 4
gpt4 key购买 nike

我不得不在 AWS 对一个应用程序进行故障排除,并且使用所有 CloudWatch 指标图来解释环境健康状况并不容易,因此我决定在这里分享我的经验。

CloudWatch 为我们提供 CPU、内存*、磁盘和网络指标。

* to get memory metrics you need to install CloudWatch Agent.

CPU 和内存为我们提供了以百分比表示的指标,该指标清晰易懂。但是磁盘和网络并不是那么容易,例如我想检查我的卷和网络 (Gbps) 的 IOPS 和吞吐量 (MiB/s)。

我需要这些值,因为 AWS 将 EBS 限制定义为 IOPS 和吞吐量 (MB/s),将实例网络限制定义为 Gbps。

最佳答案

总 IOPS
EBS Volume 为我们提供指标 VolumeReadOpsVolumeWriteOps。让我引用 AWS 文档。

VolumeReadOps - The total number of read operations in a specified period of time.
To calculate the average read operations per second (read IOPS) for the period, divide the total read operations in the period by the number of seconds in that period.

VolumeWriteOps - The total number of write operations in a specified period of time.
To calculate the average write operations per second (write IOPS) for the period, divide the total write operations in the period by the number of seconds in that period.

引用:https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cloudwatch_ebs.html

要获得总 IOPS,我们需要 (VolumeReadOps + VolumeWriteOps)/SecondsInPeriod
幸运的是 CloudWatch 帮助我们处理 Expression。使用下面的表达式,函数 PERIOD 是我们的 friend 。

m1 = VolumeWriteOps - Sum
m2 = VolumeReadOps - Sum
Expression: (m1+m2)/PERIOD(m1)

引用:https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html


总吞吐量 (MiB/s)
EBS Volume 为我们提供指标 VolumeReadBytesVolumeWriteBytes。让我引用 AWS 文档。

VolumeReadBytes - Provides information on the read operations in a specified period of time. The Sum statistic reports the total number of bytes transferred during the period.

VolumeWriteBytes - Provides information on the write operations in a specified period of time. The Sum statistic reports the total number of bytes transferred during the period.

这两个指标都以 bytes 为我们提供值,但我们希望它们以 MiB 为单位,因此要转换我们需要除以 1048576,这是 1024 * 1024 的结果。让我详细解释一下。

1024 bytes = 1 KiB
1024 KiB = 1 MiB

要获得以 MiB/s 为单位的总吞吐量,我们需要 ((VolumeReadBytes + VolumeWriteBytes)/1048576)/SecondsInPeriod
使用下面的表达式,函数 PERIOD 是我们的 friend 。

m1 = VolumeWriteBytes - Sum
m2 = VolumeReadBytes - Sum
Expression: ((m1+m2)/1048576)/PERIOD(m1)

总网络 (Gbps)
EC2 实例为我们提供指标 NetworkInNetworkOut。让我引用 AWS 文档。

NetworkIn - The number of bytes received on all network interfaces by the instance. This metric identifies the volume of incoming network traffic to a single instance.
The number reported is the number of bytes received during the period. If you are using basic (five-minute) monitoring, you can divide this number by 300 to find Bytes/second. If you have detailed (one-minute) monitoring, divide it by 60.

NetworkOut - The number of bytes sent out on all network interfaces by the instance. This metric identifies the volume of outgoing network traffic from a single instance.
The number reported is the number of bytes sent during the period. If you are using basic (five-minute) monitoring, you can divide this number by 300 to find Bytes/second. If you have detailed (one-minute) monitoring, divide it by 60.

引用:https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html

这两个指标都以每周期字节数为我们提供值,但我们希望它们以千兆位/秒为单位。
要从“period”转换为“second”,我们只需要除以 300(因为我使用的是标准监控)。

要将 bytes 转换为 gigabits,我们需要除以 0.008,这是 (1000/1000/1000) * 8。让我详细解释一下。

1000 bits = 1 kilobits
1000 kilobits = 1 megabits
1000 megabits = 1 gigabits
1 byte = 8 bits

要获得以 Gbps 为单位的总网络,我们需要 ((NetworkIn + NetworkOut)/300)/0.008

m1 = NetworkIn - Sum
m2 = NetworkOut - Sum
Expression: ((m1+m2)/300)/0.008

关于amazon-web-services - 卷 IOPS、卷吞吐量 (MiB/s) 和网络 (Gbps) 的 CloudWatch 指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60900782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com