简体   繁体   中英

How can i set the az monitor command to get time period data in Powershell?

I use the Az cmd below

az monitor metrics list --resource <resourceid>  --metrics "CpuPercentage"

This give metrics for the last hour. Is there any parameters i can add to get the average over a small period eg 5 minutes and check if that exceeds a threshold (usually 75-80%)?

You can give time interval like below, which gives average usage of CPU in last 5 minutes but for each minutes.

az monitor metrics list --resource <resourceId> --metric 'Percentage CPU' --interval PT1M --start-time $(date -u +"%Y-%m-%dT%H:%M:%SZ" --date='5 minutes ago') --end-time $(date -u +"%Y-%m-%dT%H:%M:%SZ" --date='0 minute ago') --aggregation Average

Please find examples here - https://learn.microsoft.com/en-us/cli/azure/monitor/metrics?view=azure-cli-latest

To find a threshold that exceeds certain limit you need to set an alert. Please find more about that here - https://learn.microsoft.com/en-us/cli/azure/monitor/metrics/alert/condition?view=azure-cli-latest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM