I would like to set up an alert for the following scenario:
A pipeline agent that has been scaled up by a scale set runs for more than 1 hour.
Unfortunately, I only see the possibility to set alarms for the entire VMSS but not for its individual agents.
Thank you
To set alarms for an individual VM in VMSS, you can refer to the following steps.
Go to Monitor -> Alerts -> Create -> Alert rule.
Click the drop-down button of your target subscription, resource group, and VMSS in sequence. You can set the scope to an individual VM.
Then you can see the scope like this:
However, I haven't seen a Condition that can be used to monitor the running time of the VM.
Update
As a workaround, you can create a new pipeline and set the pipeline running on your VMSS as the pipeline resource. When the resource pipeline is completed, the new pipeline will be triggered. In the new pipeline, run REST API Builds - Get to get the total running time of the resource pipeline. If the running time exceeds 60 minutes, then use the task Send Email to send the email to your target account.
In the
PowerShell@2
task, if the running time of the resource pipeline exceeds 60 minutes, create an output variablesendnotification
and set its value to true. Use condition to limit theSendEmail@1
task to run only when the value of sendnotification is "True".