0
votes

I have set up a log-based alert in Microsoft Azure. The deployment of the alerts done via ARM template. Where you can input your query and set threshold like below.

 "triggerThresholdOperator": {
        "value": "GreaterThan"
      },
      "triggerThreshold": {
        "value": 0
      },
      "frequencyInMinutes": {
        "value":15
      },
      "timeWindowInMinutes": {
        "value": 15
      },
      "severityLevel": {
        "value": "0"
      },
      "appInsightsQuery": {
        "value": "exceptions\r\n| where A_ != '2000' \r\n| where A_ != '4000' \r\n| where A_ != '3000' "
      }

As far as I understand we can only set threshold once ON an entire query.

Questions: I have multiple statements in my query which I am excluding since it's just a noise. But now I want to set a threshold on value 3000 to 5 and also want to set a time-window to 30 in the same query. meaning only exclude 3000 when it occurs 5 times in the last 30 minutes(when query get run).

exceptions
| where A_ != '2000' 
| where A_ != '4000' 
| where A_ != '3000' 

I am pretty sure that I can't set a threshold like this in the query and the only workaround is to create a new alert just for value 3000 and set a threshold in ARM template. I haven't found any heavy threshold/time filters in Aure. Is there any way I can set multiple thresholds and time filters in a single query? which is again getting checked by different threshold and time filetrs in the ARM template.

Thanks.

2

2 Answers

0
votes

I don't fully understand your question.

But for your time window question you could do something like

exceptions
| summarize count() by A_, bin(TimeGenerated, 30m)

That way you will get a count of A_ in blocks of 30 minutes.

Another way would be to do:

let Materialized = materialize(
exceptions
| summarize Count=count(A_) by bin(TimeGenerated, 30m)
); 
Materialized | where Count == 10

But then again it all depends on what you would like to achieve

0
votes

You can easily set that in the query and fire based on the aggregate result.

exceptions
| where timestamp > ago(30m)
| summarize count2000 = countif(A_ == '2000'), count3000 = countif(A_ == '3000'), count4000 = countif(A_ == '4000')
| where count2000 > 5 or count3000 > 3 or count4000 > 4

If the number of results is greater than one than the aggregate condition applies.