【问题标题】:What is the format of azure monitor metric alert conditions in Azure CLI?Azure CLI 中 Azure Monitor 指标警报条件的格式是什么?
【发布时间】:2019-06-12 02:15:36
【问题描述】:

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

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

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

【问题讨论】:

    标签: azure azure-cli azure-monitoring azure-sdk azure-sdk-python


    【解决方案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.
    

    【讨论】:

      【解决方案2】:

      如果您有一个包含点“.”的自定义指标或冒号':'那么这并不容易,我没有找到任何文档。幸运的是,我找到了 metric condition parser rule,您可以在其中阅读条件应该是什么样子。

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

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

      【讨论】:

      • “度量条件解析器”链接已损坏
      • 谢谢,new link
      猜你喜欢
      • 1970-01-01
      • 2022-12-01
      • 2021-04-16
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-26
      • 1970-01-01
      相关资源
      最近更新 更多