Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created December 6, 2019 16:44
Show Gist options
  • Save PrateekKumarSingh/91c329724f8be157c487b214051d3a53 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/91c329724f8be157c487b214051d3a53 to your computer and use it in GitHub Desktop.
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