DxG
DxG

Reputation: 209

Azure monitor alert using minimum failing periods for static threshold

I'm trying to add failingPeriods for static threshold similar to https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/metricalerts?pivots=deployment-language-arm-template#multimetriccriteria-objects-1. I see it is not supported for static threshold. Is there a workaround to achieve this ?

Sample Bicep:

resource alert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
  name: 'testalert'
  location: 'location'
  properties: {
    description: 'testalert'
    severity: 3
    enabled: true
    scopes: [
      //id
    ]
    evaluationFrequency: 'PT5M'
    windowSize: 'PT5M'
    criteria: {
      allOf: [
        {
          threshold: 0
          name: 'DeadLetteredCount'
          metricNamespace: 'microsoft.eventgrid/topics'
          metricName: 'DeadLetteredCount'
          operator: 'greaterthan'
          timeAggregation: 'count'
          criterionType: 'StaticThresholdCriterion'
          failingPeriods: {
            numberOfEvaluationPeriods: 3
            minFailingPeriodsToAlert: 2
          }
        }
      ]
      'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
    }
    autoMitigate: false
    targetResourceType: 'Microsoft.EventGrid/topics'
    targetResourceRegion: location
    actions: [
      {
        actionGroupId: actionGroupId
      }
    ]
  }
}

Upvotes: 0

Views: 107

Answers (1)

Jahnavi
Jahnavi

Reputation: 8018

There will be no minimum or any failing Periods for static threshold in configuring alert rules. Because the static threshold criterion type chooses fixed values that doesn't change over time and hence the minimum failing periods are not required in this case.

Usually, Minimum failing periods means the number of consecutive periods for which a metric must fail to meet the threshold before an alert is triggered as detailed in this blog.

According to the MSDoc,

A static threshold evaluates the rule by using the threshold value that you configure.

After searching on this relevant requirement, I have tried to add the failing periods for static threshold and created an alert rule as shown below. The alert rule has been successfully created but the warning showed when I pointed at failing periods in the code.

enter image description here

Referring to the blog by @Tobias for static threshold alert rule, I have used below code as explained earlier.

resource metricalerts 'microsoft.insights/metricalerts@2018-03-01' = {
  name: xxx
  location: 'global'
  properties: {
    severity: 1
    enabled: true
    scopes: [
      Id
    ]
    evaluationFrequency: 'PT5M'
    windowSize: 'PT5M'
    criteria: {
      allOf: [
        {
          threshold: 1
          name: 'Metric1'
          metricNamespace: 'Microsoft.Web/sites'
          metricName: 'Http4xx'
          operator: 'GreaterThan'
          timeAggregation: 'Total'
          criterionType: 'StaticThresholdCriterion'
          failingPeriods: {
            numberOfEvaluationPeriods: 3
            minFailingPeriodsToAlert: 2
          }
        }
      ]
      'odata.type': 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria'
    }
    autoMitigate: true
    targetResourceType: 'Microsoft.Web/sites'
    actions: [
      {
        actionGroupId: actionGroupId
        webHookProperties: {}
      }
    ]
  }
}

Deployment succeeded:

enter image description here

enter image description here

Also, you can refer this blog by @Rachel Berry to understand the difference between static and dynamic thresholds more clearly.

Upvotes: 0

Related Questions