简体   繁体   English

Azure CLI 中 azure 监视器指标警报条件的格式是什么?

[英]What is the format of azure monitor metric alert conditions in Azure CLI?

The documentation for az monitor metrics alert create does not explain the format used for --conditon parameter. az 监视器指标警报创建的文档没有解释用于--conditon参数的格式。 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 .在我看来,该值最终作为allOf参数传递给MetricAlertSingleResourceMultipleMetricCriteria 类的构造函数,如metric_alert.pyAzure CLI 源中所示 However this would mean this is a list of MetricCritieria , but the documentation examples are as follows:然而,这意味着这是一个MetricCritieria列表,但文档示例如下:

--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]这看起来不像list[MetricCritieria]的有效格式list[MetricCritieria]

The detailed format description is given upon calling with the -h flag:使用-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.

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:例如,我的指标称为Ori.EventHub:DeliveryTime ,因此条件切换应如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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