How to fetch no. of request in Azure Metrics using powershell?

mayur sanap 31 Reputation points
2022-10-11T07:57:05.21+00:00

I have Front Door and CDN profiles on Azure platform, in which I go to the metrics and apply the parameter 'no. of request' to get the total no. of count for the month & download the excel for details information. As this is manual task , I need to check the same information using powershell.

How to fetch no. of request in Azure Metrics using powershell?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,802 questions
Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
576 questions
Azure AI Metrics Advisor
Azure AI Metrics Advisor
An Azure artificial intelligence analytics service that proactively monitors metrics and diagnoses issues.
80 questions
Azure Content Delivery Network
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
0 comments No comments
{count} votes

Accepted answer
  1. tbgangav-MSFT 10,381 Reputation points
    2022-10-26T07:32:01.163+00:00

    Hi @mayur sanap ,

    You could fetch the Front Door and CDN profiles no. of requests metric data using Get-AzMetric Azure PowerShell cmdlet.

    Just FYI, these and these are the Azure Monitor supported metrics for CDN profiles and Front Door respectively.

    Below is a sample command to get no. of requests for Front Door:

    Get-AzMetric -ResourceId "/subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUPNAME>/providers/Microsoft.Network/frontdoors/<FRONTDOORNAME>" -MetricName "RequestCount" -TimeGrain 00:01:00 -DetailedOutput  
    

    254212-image.png

    Below is a sample command to get no. of requests for CDN profiles:

    Get-AzMetric -ResourceId "/subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUPNAME>/providers/microsoft.cdn/profiles/<CDNPROFILENAME>" -MetricName "RequestCount" -TimeGrain 00:01:00 -DetailedOutput  
    

    254202-image.png

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. mayur sanap 31 Reputation points
    2022-11-29T07:35:45.29+00:00

    Thank you for your reply. Yes. I did it in the same way & used |select-object -property to get the selected data only & I received desired output by . here it is.

    $Rcount=
    (Get-AzMetric -ResourceId "/subscriptions/******/resourceGroups/******/providers/Microsoft.Network/frontdoors/******" \-MetricName "RequestCount" -AggregationType "Total" -TimeGrain $timeGrain -Starttime $startTime -Endtime $endTime).Data
    |select-object -property Total

    0 comments No comments