Get-Metrics
Applies To: Azure PowerShell 1.0
Get-Metrics
Gets the metric values of a resource.
Syntax
Parameter Set: Default
Get-Metrics [-ResourceId] <String> [-TimeGrain] <TimeSpan> [-DetailedOutput] [-EndTime <DateTime> ] [-MetricNames <String[]> ] [-StartTime <DateTime> ] [ <CommonParameters>]
Detailed Description
The Get-Metrics cmdlet gets the metric values of a resource that comply with specified criteria.
Parameters
-DetailedOutput
Indicates that the output is detailed. The default is summarized output.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-EndTime<DateTime>
Specifies the end time and date, as a DateTime object, to search for metric values.
You can use the Get-Date cmdlet to get a DateTime object.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-MetricNames<String[]>
Specifies an array of names of metrics.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-ResourceId<String>
Specifies the resource ID with which the metric is associated.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-StartTime<DateTime>
Specifies the start date and time, as a DateTime object, to search for metric values.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-TimeGrain<TimeSpan>
Specifies the time grain of the metric in the format hh:mm:ss.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
Examples
Example 1: Get metrics with summarized output
This command gets the metric values for website3 with a time grain of 1 minute.
PS C:\> Get-Metrics -ResourceId "/subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/ResourceGroups/Contoso-Web-EastUS/providers/microsoft.web/sites/website3" -TimeSpan 00:01:00
OUTPUT:
DimensionName :
DimensionValue :
Name : AverageResponseTime
EndTime : 3/20/2015 6:40:46 PM
MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue,
Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...}
Properties : {}
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/ResourceGroups/Contoso-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:40:00 PM
TimeGrain : 00:01:00
Unit : Seconds
DimensionName :
DimensionValue :
Name : AverageMemoryWorkingSet
EndTime : 3/20/2015 6:40:46 PM
MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue,
Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...}
Properties : {}
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:40:00 PM
TimeGrain : 00:01:00
Unit : Bytes
Example 2: Get metrics with detailed output
This command gets the metric values for website3 with a time grain of 1 minute. The output is detailed.
PS C:\> Get-Metrics -ResourceId "/subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/ResourceGroups/Contoso-Web-EastUS/providers/microsoft.web/sites/website3" -TimeSpan 00:01:00 -DetailedOutput
OUTPUT:
MetricValues :
Average : 0
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:37:00 PM
Total : 0
Average : 0.106
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:39:00 PM
Total : 0.106
Average : 0.064
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:41:00 PM
Total : 0.064
Properties :
DimensionName :
DimensionValue :
Name : AverageResponseTime
EndTime : 3/20/2015 6:43:33 PM
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/ResourceGroups/Contoso-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:43:00 PM
TimeGrain : 00:01:00
Unit : Seconds
Example 3: Get filtered and detailed metrics
This command gets the metrics named Requests, using the specified resource ID and time span.
PS C:\> Get-Metrics -ResourceId "/subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/ResourceGroups/Contoso-Web-EastUS/providers/microsoft.web/sites/website3" -TimeSpan 00:01:00 -DetailedOutput -MetricNames 'Requests'
OUTPUT:
MetricValues :
Average : 1
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:39:00 PM
Total : 1
Average : 1
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:41:00 PM
Total : 1
Average : 0
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:43:00 PM
Total : 0
Average : 1
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:44:00 PM
Total : 1
Average : 0
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:45:00 PM
Total : 0
Properties :
DimensionName :
DimensionValue :
Name : Requests
EndTime : 3/20/2015 6:47:56 PM
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/ResourceGroups/Contoso-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:47:00 PM
TimeGrain : 00:01:00
Unit : Count