0

I'm trying to get AWS CloudWatch metric datapoints with powershell. But Get-CWMetricStatistic command returns datapoints empty. When I see CloudWatch by AWS Management Console, graph data exists.

Please tell me why I cannot pick up my data points.

$Namespace="AWS/ApplicationELB"
$MetricName="HealthyHostCount"
$Statistic="Minimum"
$Period = 300

$start=[System.DateTime]::UtcNow.AddHours(-1)
$end=[System.DateTime]::UtcNow

$dim=[Amazon.CloudWatch.Model.Dimension]::new()
$dim.Name="TargetGroup"
$dim.Value="MyTargetGroup"

$dim2=[Amazon.CloudWatch.Model.Dimension]::new()
$dim2.Name="LoadBalancer"
$dim2.Value="MyELB"

Get-CWMetricStatistic -Namespace $Namespace `
    -MetricName $MetricName `
    -Statistic $Statistic `
    -UtcStartTime $start `
    -UtcEndTime $end `
    -Period $Period `
    -Dimension $dim,$dim2
Sako
  • 105
  • 1
  • 8
  • 1
    is your `$dim.Value` referring to an ID? For example: `Name='LoadBalancer'` and `Value='app/my-load-balancer/50dc6c495c0c9188'`. It looks fine otherwise, but you can get a lot of things wrong and it won't throw any errors, just an empty dataset - check out: https://stackoverflow.com/a/44790403/7411885 – Cpt.Whale Sep 24 '21 at 20:55
  • Thanks for your comment. It was just format mistake of $dim.Value and $dim2.Value. As you mentioned , add ID for $dim.Value, and it returned datasets. – Sako Sep 29 '21 at 07:25

0 Answers0