using customProperties in a Microsoft.Insights/scheduledQueryRules@2023-03-15-preview bicep

fadoua bendefa 0 Reputation points
2024-10-04T20:45:12.8733333+00:00

Hi

I am trying to use the customProperties in the following bicep. I would like to add the result of the query as a property to the action.

however there is so little documentation and I am not sure I understand the difference between actionProperties and customProperties. is there a way to achieve what I want? and is there any extra documentation about how to fill these fields dynamically?

thanks

Microsoft.Insights/scheduledQueryRules@2023-03-15-preview
resource incidentAlertRule 'Microsoft.Insights/scheduledQueryRules@2023-03-15-preview' = {
  name: 'service-health-alert-${environment}-subscriptions'
  location: location
  tags: tags
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    description: 'Service Health alerts for incidents'
    severity: 4
    enabled: true
    autoMitigate: false
    scopes: [
      existingLogAnalyticsWorkspace.id
    ]
    evaluationFrequency: 'PT15M'
    windowSize: 'PT15M'
    criteria: {
      allOf: [
        {
          query: 'AzureActivity | where CategoryValue == "ServiceHealth" | extend TrackingId = Properties_d.trackingId, Service = Properties_d.service, Title = Properties_d.defaultLanguageTitle, Content = Properties_d.defaultLanguageContent, Type = Properties_d.incidentType | project TrackingId, TimeGenerated, Service, Type, Level, Title, Content, CorrelationId | where tostring(Type) == "Incident" | summarize take_any(*) by CorrelationId | order by TimeGenerated desc'
          timeAggregation: 'Count'
          operator: 'GreaterThanOrEqual'
          threshold: 1
        }
      ]
    }
    actions: {
      actionGroups: [
        serviceHealthActionGroup.id
      ]
      customProperties: {
        result: '$(Result)'
      }
    }
  }
}
Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,285 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 24,376 Reputation points MVP
    2024-10-07T07:59:49.62+00:00

    Hi,

    I believe the correct property is customProperties. As far as I know actionProperties is incorrectly published to the schema of the resource provider and it will not work. How you can pass dynamic values and the syntax for dynamic values is described in Configure alert rule details step 5. Note that you can only add values that are part of the common alert schema. For example, log alerts v2 do not include the search results. They include links that you can use to get the search results. If you want some column value from the query to be included in the search results you need to add that column as dimension. The column also needs to be of type string. Also by adding the column as dimension that means that the alert rule will be fired for each different value for that dimension separately when the threshold is met.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.