【问题标题】:az cli schedule-query --condition not workingaz cli schedule-query --condition 不工作
【发布时间】:2022-11-05 01:06:29
【问题描述】:

我正在尝试使用 az cli schedule-query 命令预配 Azure 警报,但在使用 --condition 时遇到了困难。

以下是我试图通过 az cli 提供的内容:

我使用的命令是:

az monitor scheduled-query create --condition "avg 'AggregatedValue' > 1 at least 1 violations out of 5 aggregated points" \
                                  --condition-query "KubeEvents \n| where ClusterName =~ 'esg-aks-asse-aks-d'\n| where ObjectKind =~ 'Pod'\n| where Reason =~ 'BackOff'\n| project TimeGenerated, Name, ObjectKind, Reason, Message, Namespace, Count\n| summarize AggregatedValue=sum(Count) by bin(TimeGenerated, 5m) \n" \
                                  --name "esg-txc-dev-podbackoff" \
                                  --resource-group "<myrg>" \
                                  --scopes "<myscope>" \
                                  --target-resource-type "Kubernetes service" \
                                  --action-groups "<myactiongroup>" \
                                  --description "Pod Back Off Alert" \
                                  --evaluation-frequency "5m" \
                                  --severity 2 \
                                  --skip-query-validation false \
                                  --window-size "5m"

但是,当我运行它时收到以下错误:

无论如何/指南如何在 Azure Portal UI 中获得等效的 --condition ?

谢谢

【问题讨论】:

    标签: azure command-line-interface


    【解决方案1】:

    我也努力让这个工作。 由于我在尝试创建警报规则后遇到的错误,终于找到了它: [powershell错误][1] [1]:https://i.stack.imgur.com/LegzI.png

    声明“[“公制列”来自]” 这让我使用了这样的东西

    $condqry=ApiManagementGatewayLogs | summarize cnt=count() by bin(TimeGenerated,1h)
    $cond= "max cnt from 'QRY1' > 30"
    
    az monitor scheduled-query create
      --name "fat-test" 
      --condition $cond 
      --condition-query QRY1="$condqry" 
      --scopes <yourscope> 
      --resource-group $ALERT_RESOURCE_GROUP 
      --window-size 30m
      --evaluation-frequency 30m
      --description "Test alert" 
      --severity 1
    

    哪里“最大数量从"是最重要的部分

    【讨论】:

      猜你喜欢
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多