简体   繁体   English

AWS Powershell - 用于EBS的Get-CWMetricStatistics读取IOPS

[英]AWS Powershell - Get-CWMetricStatistics for EBS Read IOPS

I'm having some issues getting IOPs stats for EBS volumes, using this code: 我在使用以下代码获取EBS卷的IOPs统计数据时遇到了一些问题:

Get-CWMetricList -Namespace AWS/EC2 |Select-Object * -Unique

Get-CWMetricList -Namespace AWS/EBS |Select-Object * -Unique

$StartDate = (Get-Date).AddDays(-3)
$EndDate = Get-Date
$ReadIOPS = Get-CWMetricStatistics -Namespace "AWS/EC2" -MetricName "DiskReadOps" -UtcStartTime $StartDate -UtcEndTime $EndDate -Period 300 -Statistics @("Average") 
$ReadIOPS.Datapoints.Count  
$ReadIOPS = Get-CWMetricStatistics  -Namespace "AWS/EBS" -MetricName "VolumeReadOps" -UTCStartTime $StartDate -UTCEndTime $EndDate -Period 300  -Statistics @("Average")
$ReadIOPS.Datapoints.Count

Top 2 lines show that the Namespace/Metrics Names are correct. 前2行显示命名空间/度量标准名称是正确的。 Rest should show that the first query in the AWS/EC2 name space gets data, however the 2nd in the AWS/EBS namespace doesn't. Rest应显示AWS / EC2名称空间中的第一个查询获取数据,但AWS / EBS命名空间中的第二个查询不会。

The ultimate goal is to add a -dimension tag and grab all read/write iops for a particular volumed. 最终目标是添加一个-dimension标记并获取特定容量的所有读/写iops。 This is why the AWS/EC2 namespace doens't work as I need to specify a volume id and not an instance ID. 这就是AWS / EC2命名空间无法工作的原因,因为我需要指定卷ID而不是实例ID。

Any ideas why I'm not picking up any datapoints on the latter query? 任何想法为什么我没有在后一个查询中获取任何数据点?

Turns out that EBS stats require a Vol ID to be specified though this is not called out or errors as such. 事实证明,EBS统计数据需要指定Vol ID,尽管这不会被调出或错误。

I had stripped out the dimension to cast as wide a net as possible/back to basics when troubleshooting. 在故障排除时,我已经删除了尽可能宽的网络/返回基础知识。 Adding that back in fixed the issue: 在修复问题时添加回来:

ie. 即。 this works 这很有效

$Volume = 'vol-blah'
$dimension1 = New-Object Amazon.CloudWatch.Model.Dimension
$dimension1.set_Name("VolumeId")
$dimension1.set_Value($Volume)
$ReadIOPS = Get-CWMetricStatistics -Namespace "AWS/EBS" -MetricName "VolumeReadOps" -UTCStartTime $StartDate -UTCEndTime $EndDate -Period 300  -Statistics @("Average") -Dimension $dimension1
$ReadIOPS.Datapoints.Count

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM