0

az monitor metrics alert create的文档未解释用于--conditon参数的格式。在我看来,该值最终作为allOf参数传递给MetricAlertSingleResourceMultipleMetricCriteria 类的构造函数,如 metric_alert.py的Azure CLI 源中所示。但是,这意味着这是一个 列表MetricCritieria,但文档示例如下:

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

这看起来不像是有效的格式list[MetricCritieria]

4

2 回答 2

1

如果您有一个包含点“。”的自定义指标 或冒号':'那么这并不容易,我没有找到任何文档。幸运的是,我发现了一个度量条件解析器规则,您可以在其中阅读条件的外观。

例如,我的指标称为Ori.EventHub:DeliveryTime,因此条件开关应如下所示:

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

于 2020-01-20T13:41:49.360 回答
1

-h使用标志调用时给出了详细的格式描述:

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.
于 2019-06-12T02:35:54.587 回答