Monitor (1 / 12): You are managing a set of Azure virtual machines for a high-traffic e-commerce website. To ensure optimal performance, you decide to set up an alert for any VM that experiences high CPU usage. Specifically, you want to be notified if a VM's average CPU usage exceeds 90% over a 5-minute window, and you want this condition to be evaluated every minute. Additionally, when this alert is triggered, a specific action group should be notified. Using the Azure CLI, craft the appropriate az monitor metrics alert create
command to achieve this.
az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID} \
# Code here
--description "High CPU"
Answer:
az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID} \
--condition "avg Percentage CPU > 90" \
--window-size 5m \
--evaluation-frequency 1m \
--action {ActionGroupResourceID} \
--description "High CPU"
--scopes {VirtualMachineID}
: Specifies the ID of the virtual machine you want to monitor.
--condition "avg Percentage CPU > 90"
: Defines the alert criteria, which is an average CPU percentage greater than 90%.
--window-size 5m
: Sets the period over which the metric data is aggregated to 5 minutes.
--evaluation-frequency 1m
: Sets the frequency at which the metric data is evaluated to every minute.
--action {ActionGroupResourceID}
: Specifies the action group to be triggered when the alert fires.