Azure AppInsights - custom metrics

Hello there!

I’d like to verify/extract custom Metric Namespace from Application Insights Metrics from Azure, e.g.:

Imgur

The Metric Namespace will be enough for me, but will be great to have Metric names.
At the moment I stuck and I’m not sure if that’s possible as I’m able only to extract the standard Metric names, like:

Imgur

My steps:

Get-AzApplicationInsights -ResourceGroupName NameOfResourceGroup | Where-Object {$_.Name -like "*XXX*"} | Select Name

As a result I’ve list of eligible AppInsights:

Name                    
----                    
...-XXX-PROD
...-XXX-TEST

I’m checking what ResourceTypes are used for those AppInsights and have three unique:

Get-AzResource -ResourceGroupName NameOfResourceGroup  | Where-Object {$_.Name -like "*XXX*"} | Select ResourceType

microsoft.insights/components
Microsoft.Insights/metricalerts 
Microsoft.Insights/webtests 

Checking Microsoft.Insights/webtests with Get-AzureRmMetricDefinition:

Get-AzureRmMetricDefinition -ResourceId /subscriptions/XXX/resourceGroups/NameOfResourceGroup/providers/Microsoft.Insights/webtests/...-xxx-prod

Get-AzureRmMetricDefinition : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
   at Microsoft.Azure.Management.Monitor.MetricDefinitionsOperations.<ListWithHttpMessagesAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Monitor.MetricDefinitionsOperationsExtensions.<ListAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Monitor.MetricDefinitionsOperationsExtensions.List(IMetricDefinitionsOperations operations, String resourceUri, String metricnamespace)
   at Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricDefinitionCommand.ProcessRecordInternal()
   at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
At line:1 char:1
+ Get-AzureRmMetricDefinition -ResourceId /subscriptions/xxx- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzMetricDefinition], PSInvalidOperationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricDefinitionCommand

So nothing here.

Next Microsoft.Insights/metricalerts:

Get-AzureRmMetricDefinition -ResourceId /subscriptions/XXX/resourceGroups/NameOfResourceGroup/providers/Microsoft.Insights/metricalerts/...-xxx-prod

Get-AzureRmMetricDefinition : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
   at Microsoft.Azure.Management.Monitor.MetricDefinitionsOperations.<ListWithHttpMessagesAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Monitor.MetricDefinitionsOperationsExtensions.<ListAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Monitor.MetricDefinitionsOperationsExtensions.List(IMetricDefinitionsOperations operations, String resourceUri, String metricnamespace)
   at Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricDefinitionCommand.ProcessRecordInternal()
   at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
At line:1 char:1
+ Get-AzureRmMetricDefinition -ResourceId /subscriptions/xxx- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzMetricDefinition], PSInvalidOperationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricDefinitionCommand

Nothing here either.

So the last microsoft.insights/components:

Get-AzureRmMetricDefinition -ResourceId /subscriptions/XXX/resourceGroups/NameOfResourceGroup/providers/microsoft.insights/components/...-XXX-PROD | Select -ExpandProperty Name | Select @{Name='Metrics';Expression={$_.LocalizedValue}}

Metrics                           
-------                           
Availability                      
Availability tests                
Availability test duration        
Page load network connect time    
Client processing time            
Receiving response time           
Send request time                 
Browser page load time            
Dependency calls                  
Dependency duration               
Dependency call failures          
Page views                        
Page view load time               
HTTP request execution time       
HTTP requests in application queue
HTTP request rate                 
Exception rate                    
Process IO rate                   
Process CPU                       
Processor time                    
Available memory                  
Process private bytes             
Server response time              
Server requests                   
Failed requests                   
Server request rate               
Exceptions                        
Browser exceptions                
Server exceptions                 
Traces               

When you compare it with the above print screen with standard Metrics - they’re the same, but there’s no custom metrics.

The question is: is it possible to extract/gather such information via PowerShell about custom Metrics?