Created
December 6, 2019 16:44
-
-
Save PrateekKumarSingh/91c329724f8be157c487b214051d3a53 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Import-Module Graphical | |
# inputs | |
$WarningPreference = 'SilentlyContinue' | |
$TimeGrain = [timespan]::FromMinutes(1) | |
$MetricName = 'Percentage CPU' | |
$ResourceName = 'MyVM' | |
$Start = [datetime]::Now.AddMinutes(-90) | |
$End = [datetime]::Now.AddMinutes(-45) | |
# capture resource metrics | |
$ResourceID = (Get-AzResource -ResourceName $ResourceName).ResourceId | |
$Splat = @{ | |
ResourceId = $ResourceID | |
MetricName = $MetricName | |
TimeGrain = $TimeGrain | |
StartTime = $Start | |
EndTime = $End | |
} | |
$Data = Get-AzMetric @Splat | |
$Datpoints = $data.data.average.foreach({[int]$_}) | |
# plot the graph | |
Show-Graph -Datapoints $Datpoints -GraphTitle $MetricName -YAxisStep 5 | |
Show-Graph -Datapoints $Datpoints -GraphTitle $MetricName -YAxisStep 5 -Type Line | |
Show-Graph -Datapoints $Datpoints -GraphTitle $MetricName -YAxisStep 5 -Type Scatter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment