Share via

Get-AzMetric command is returning error when trying to access Event hub metrics

Anonymous
2023-06-13T07:52:58.3333333+00:00

I'm trying to execute Get-AzMetric  to get Event Hub metrics like Incoming messages but its throwing me the following error -

Get-AzMetric: Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'NotFound'
   at Microsoft.Azure.Management.Monitor.MetricsOperations.ListWithHttpMessagesAsync(String resourceUri, ODataQuery`1 odataQuery, String timespan, Nullable`1 interval, String metricnames, String aggregation, Nullable`1 top, String orderby, Nullable`1 resultType, String metricnamespace, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.Management.Monitor.MetricsOperationsExtensions.ListAsync(IMetricsOperations operations, String resourceUri, ODataQuery`1 odataQuery, String timespan, Nullable`1 interval, String metricnames, String aggregation, Nullable`1 top, String orderby, Nullable`1 resultType, String metricnamespace, CancellationToken cancellationToken)
   at Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricCommand.ProcessRecordInternal()
   at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null

Azure Event Hubs

1 answer

Sort by: Most helpful
  1. QuantumCache 20,681 Reputation points Moderator
    2023-06-13T14:52:49.4466667+00:00

    Hello @Srijita Mallick (ADMSMB161)

    Did you verify if the resource actually exists in the RG?

    Any permission restrictions to run the PowerShell script or updating the PowerShell module?

    1. Incorrect resource URI: Make sure that the resource URI you are using is correct and points to the Event Hub you want to retrieve metrics for. The resource URI should be in the format /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}.
    2. Insufficient permissions: Make sure that the account you are using to run the Get-AzMetric command has sufficient permissions to access the Event Hub. You may need to grant the account the appropriate permissions using Azure RBAC.
    3. Event Hub not found: Make sure that the Event Hub you are trying to retrieve metrics for exists and is in the same region as the Azure PowerShell session you are running the command in.
    4. Incorrect metric name: Make sure that the metric name you are using is correct and matches the available metrics for the Event Hub. You can use the Get-AzMetricDefinition command to retrieve a list of available metrics for the Event Hub.

    I hope this helps! Let me know if you have any other questions.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.