排除KQL SLA图表中的数据

时间:2019-07-08 08:56:59

标签: azure powershell alerts kql

如果有计划的维护,我们将显示URL,VPN和VM的SLA图表,我们希望将KQL SLA图表中的时间排除在已知停机时间之外。

在这段时间中,我们将下面的列传递给Loganalytics自定义表,从而通过Powershell禁用警报。

     "resourcename": "$resourcename",
     "Alertstate": "Enabled",
     "Scheduledmaintenance" : "stop",
     "Environment" : "UAT",
     "timestamp": "$TimeStampField",

    Now we want to use join condition SLA charts queries  with custom table data and exclude the time range in SLA charts during scheduled maintenance.

    Adding query as per request
    ---------------------------

    url_json_CL
    | where Uri_s contains "xxxx"
    | extend Availablity = iff(StatusCode_d ==200,1.000,0.000)
    | extend urlhit = 1.000
    | summarize PassCount = sum(Availablity), TestCount = sum(urlhit) by Uri_s ,ClientName_s
    | extend AVLPERCENTAGE = ((PassCount / TestCount ) * 100)
    | join kind=leftouter 
(  scheduledmaintenance2_CL
     | where ResourceName_s == "VMname" 
     | where ScheduledMaintenance_s == "start" 
     | extend starttime = timestamp_t)
     on ClientName_s
    | join kind= leftouter
     (scheduledmaintenance2_CL
     | where ResourceName_s == "VMname" 
     | where ScheduledMaintenance_s == "stop" 
     | extend stoptime = timestamp_t )
     on ClientName_s
     | extend excludedtime=stoptime - starttime  
     | project ClientName_s, ResourceName_s, excludedtime, AVLPERCENTAGE , Uri_s 
     | top 3 by  ClientName_s  desc

1 个答案:

答案 0 :(得分:0)

您可以在Azure Monitor中执行跨资源日志查询

  1. 使用Application Insights浏览器,我们还可以查询Log Analytics工作区自定义表。

workspace("/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourcegroups/rgname/providers/Microsoft.OperationalInsights/workspaces/workspacename").Event | count

  1. 使用Log Analytics日志浏览器可以查询Application Insights可用性结果

app("applicationinsightsinstancename").availabilityResults

您可以使用上述任何选项来查询所需的表并联接这些表。请参阅this有关联接的文档。

Additional documentation reference

希望这会有所帮助。