Last active
January 10, 2018 01:02
-
-
Save avvi00/cc095e250001399ef400087738b19f45 to your computer and use it in GitHub Desktop.
Get EC2 cloudwatch metric for instance in powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum MetricStat { | |
Minimum | |
Maximum | |
Average | |
SampleCount | |
Sum | |
} | |
$metricName = 'CPUCreditBalance' | |
$instance = 'zzzzzzzzzzz' | |
$stat = [MetricStat]::Average | |
$start = [datetime]::Parse('2018-01-01') | |
$end = [DateTime]::Parse('2018-01-09') | |
$period = 3600 | |
$stat = Get-CWMetricStatistic -Dimension @{'Name'='InstanceId';'Value'= $instance} -MetricName $metricName -Statistic $stat.ToString() -StartTime $start -EndTime $end -Period $period -Namespace 'AWS/EC2' | |
$stat.Datapoints | Select Timestamp, Average | Sort-object Timestamp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment