0

The documentation for az monitor metrics alert create does not explain the format used for --conditon parameter. Seems to me the value ends up being passed as allOf argument to constructor of MetricAlertSingleResourceMultipleMetricCriteria class as seen in the Azure CLI source for metric_alert.py. However this would mean this is a list of MetricCritieria, but the documentation examples are as follows:

--condition "total transactions > 5 where ResponseType includes Success" 
--condition "avg SuccessE2ELatency > 250 where ApiName includes GetBlob or PutBlob"

which doesn't look like a valid format for the list[MetricCritieria]

Konrad Jamrozik
  • 3,254
  • 5
  • 29
  • 59

2 Answers2

1

The detailed format description is given upon calling with the -h flag:

PS> az monitor metrics alert create -h          
Command
    az monitor metrics alert create : Create a metric-based alert rule.

Arguments
    --condition         [Required] : The condition which triggers the rule.
        Usage:  --conditon {avg,min,max,total,count} [NAMESPACE.]METRIC {=,!=,>,>=,<,<=} THRESHOLD
                           [where DIMENSION {includes,excludes} VALUE [or VALUE ...]
                           [and   DIMENSION {includes,excludes} VALUE [or VALUE ...] ...]]

        Dimensions can be queried by adding the 'where' keyword and multiple dimensions can be
        queried by combining them with the 'and' keyword.

        Values for METRIC, DIMENSION and appropriate THRESHOLD values can be obtained from `az
        monitor metrics list-definition` command.

        Multiple conditons can be specified by using more than one `--condition` argument.
Konrad Jamrozik
  • 3,254
  • 5
  • 29
  • 59
1

If you have a custom metrics which contains dot '.' or colon ':' then it is not so easy and I did not find any documentation. Fortunately what I found was a metric condition parser rule where you can read how the condition should look like.

So for example my metric is called Ori.EventHub:DeliveryTime, so the condition switch should look like:

az monitor metrics alert create --condition "avg Azure.ApplicationInsights.'Ori.EventHub:DeliveryTime' > 100" .