Microsoft.AlertsManagement prometheusRuleGroups

Bicep resource definition

The prometheusRuleGroups resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.AlertsManagement/prometheusRuleGroups resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.AlertsManagement/prometheusRuleGroups@2023-03-01' = {
  location: 'string'
  name: 'string'
  properties: {
    clusterName: 'string'
    description: 'string'
    enabled: bool
    interval: 'string'
    rules: [
      {
        actions: [
          {
            actionGroupId: 'string'
            actionProperties: {
              {customized property}: 'string'
            }
          }
        ]
        alert: 'string'
        annotations: {
          {customized property}: 'string'
        }
        enabled: bool
        expression: 'string'
        for: 'string'
        labels: {
          {customized property}: 'string'
        }
        record: 'string'
        resolveConfiguration: {
          autoResolved: bool
          timeToResolve: 'string'
        }
        severity: int
      }
    ]
    scopes: [
      'string'
    ]
  }
  tags: {
    {customized property}: 'string'
  }
}

Property Values

Microsoft.AlertsManagement/prometheusRuleGroups

Name Description Value
location The geo-location where the resource lives string (required)
name The resource name string

Constraints:
Pattern = ^[^:@/#{}%&+*<>?]+$ (required)
properties The Prometheus rule group properties of the resource. PrometheusRuleGroupProperties (required)
tags Resource tags Dictionary of tag names and values. See Tags in templates

PrometheusRule

Name Description Value
actions Actions that are performed when the alert rule becomes active, and when an alert condition is resolved. PrometheusRuleGroupAction[]
alert Alert rule name. string
annotations The annotations clause specifies a set of informational labels that can be used to store longer additional information such as alert descriptions or runbook links. The annotation values can be templated. PrometheusRuleAnnotations
enabled Enable/disable rule. bool
expression The PromQL expression to evaluate. https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated periodically as given by 'interval', and the result recorded as a new set of time series with the metric name as given by 'record'. string (required)
for The amount of time alert must be active before firing. string
labels Labels to add or overwrite before storing the result. PrometheusRuleLabels
record Recorded metrics name. string
resolveConfiguration Defines the configuration for resolving fired alerts. Only relevant for alerts. PrometheusRuleResolveConfiguration
severity The severity of the alerts fired by the rule. Must be between 0 and 4. int

PrometheusRuleAnnotations

Name Description Value

PrometheusRuleGroupAction

Name Description Value
actionGroupId The resource id of the action group to use. string
actionProperties The properties of an action group object. PrometheusRuleGroupActionProperties

PrometheusRuleGroupActionProperties

Name Description Value

PrometheusRuleGroupProperties

Name Description Value
clusterName Apply rule to data from a specific cluster. string
description Rule group description. string
enabled Enable/disable rule group. bool
interval The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and 15 minutes string
rules Defines the rules in the Prometheus rule group. PrometheusRule[] (required)
scopes Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with one scope. This may change in future. string[] (required)

PrometheusRuleLabels

Name Description Value

PrometheusRuleResolveConfiguration

Name Description Value
autoResolved Enable alert auto-resolution. bool
timeToResolve Alert auto-resolution timeout. string

TrackedResourceTags

Name Description Value

Usage Examples

Bicep Samples

A basic example of deploying Alert Management Prometheus Rule Group.

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource account 'Microsoft.Monitor/accounts@2023-04-03' = {
  name: resourceName
  location: location
  properties: {
    publicNetworkAccess: 'Enabled'
  }
}

resource prometheusRuleGroup 'Microsoft.AlertsManagement/prometheusRuleGroups@2023-03-01' = {
  name: resourceName
  location: location
  properties: {
    clusterName: ''
    description: ''
    enabled: false
    rules: [
      {
        enabled: false
        expression: '''histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service="billing-processing"}[5m])) by (job_type))
'''
        labels: {
          team: 'prod'
        }
        record: 'job_type:billing_jobs_duration_seconds:99p5m'
      }
    ]
    scopes: [
      account.id
    ]
  }
}

ARM template resource definition

The prometheusRuleGroups resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.AlertsManagement/prometheusRuleGroups resource, add the following JSON to your template.

{
  "type": "Microsoft.AlertsManagement/prometheusRuleGroups",
  "apiVersion": "2023-03-01",
  "name": "string",
  "location": "string",
  "properties": {
    "clusterName": "string",
    "description": "string",
    "enabled": "bool",
    "interval": "string",
    "rules": [
      {
        "actions": [
          {
            "actionGroupId": "string",
            "actionProperties": {
              "{customized property}": "string"
            }
          }
        ],
        "alert": "string",
        "annotations": {
          "{customized property}": "string"
        },
        "enabled": "bool",
        "expression": "string",
        "for": "string",
        "labels": {
          "{customized property}": "string"
        },
        "record": "string",
        "resolveConfiguration": {
          "autoResolved": "bool",
          "timeToResolve": "string"
        },
        "severity": "int"
      }
    ],
    "scopes": [ "string" ]
  },
  "tags": {
    "{customized property}": "string"
  }
}

Property Values

Microsoft.AlertsManagement/prometheusRuleGroups

Name Description Value
apiVersion The api version '2023-03-01'
location The geo-location where the resource lives string (required)
name The resource name string

Constraints:
Pattern = ^[^:@/#{}%&+*<>?]+$ (required)
properties The Prometheus rule group properties of the resource. PrometheusRuleGroupProperties (required)
tags Resource tags Dictionary of tag names and values. See Tags in templates
type The resource type 'Microsoft.AlertsManagement/prometheusRuleGroups'

PrometheusRule

Name Description Value
actions Actions that are performed when the alert rule becomes active, and when an alert condition is resolved. PrometheusRuleGroupAction[]
alert Alert rule name. string
annotations The annotations clause specifies a set of informational labels that can be used to store longer additional information such as alert descriptions or runbook links. The annotation values can be templated. PrometheusRuleAnnotations
enabled Enable/disable rule. bool
expression The PromQL expression to evaluate. https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated periodically as given by 'interval', and the result recorded as a new set of time series with the metric name as given by 'record'. string (required)
for The amount of time alert must be active before firing. string
labels Labels to add or overwrite before storing the result. PrometheusRuleLabels
record Recorded metrics name. string
resolveConfiguration Defines the configuration for resolving fired alerts. Only relevant for alerts. PrometheusRuleResolveConfiguration
severity The severity of the alerts fired by the rule. Must be between 0 and 4. int

PrometheusRuleAnnotations

Name Description Value

PrometheusRuleGroupAction

Name Description Value
actionGroupId The resource id of the action group to use. string
actionProperties The properties of an action group object. PrometheusRuleGroupActionProperties

PrometheusRuleGroupActionProperties

Name Description Value

PrometheusRuleGroupProperties

Name Description Value
clusterName Apply rule to data from a specific cluster. string
description Rule group description. string
enabled Enable/disable rule group. bool
interval The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and 15 minutes string
rules Defines the rules in the Prometheus rule group. PrometheusRule[] (required)
scopes Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with one scope. This may change in future. string[] (required)

PrometheusRuleLabels

Name Description Value

PrometheusRuleResolveConfiguration

Name Description Value
autoResolved Enable alert auto-resolution. bool
timeToResolve Alert auto-resolution timeout. string

TrackedResourceTags

Name Description Value

Usage Examples

Terraform (AzAPI provider) resource definition

The prometheusRuleGroups resource type can be deployed with operations that target:

  • Resource groups

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.AlertsManagement/prometheusRuleGroups resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.AlertsManagement/prometheusRuleGroups@2023-03-01"
  name = "string"
  parent_id = "string"
  location = "string"
  tags = {
    {customized property} = "string"
  }
  body = {
    properties = {
      clusterName = "string"
      description = "string"
      enabled = bool
      interval = "string"
      rules = [
        {
          actions = [
            {
              actionGroupId = "string"
              actionProperties = {
                {customized property} = "string"
              }
            }
          ]
          alert = "string"
          annotations = {
            {customized property} = "string"
          }
          enabled = bool
          expression = "string"
          for = "string"
          labels = {
            {customized property} = "string"
          }
          record = "string"
          resolveConfiguration = {
            autoResolved = bool
            timeToResolve = "string"
          }
          severity = int
        }
      ]
      scopes = [
        "string"
      ]
    }
  }
}

Property Values

Microsoft.AlertsManagement/prometheusRuleGroups

Name Description Value
location The geo-location where the resource lives string (required)
name The resource name string

Constraints:
Pattern = ^[^:@/#{}%&+*<>?]+$ (required)
properties The Prometheus rule group properties of the resource. PrometheusRuleGroupProperties (required)
tags Resource tags Dictionary of tag names and values.
type The resource type "Microsoft.AlertsManagement/prometheusRuleGroups@2023-03-01"

PrometheusRule

Name Description Value
actions Actions that are performed when the alert rule becomes active, and when an alert condition is resolved. PrometheusRuleGroupAction[]
alert Alert rule name. string
annotations The annotations clause specifies a set of informational labels that can be used to store longer additional information such as alert descriptions or runbook links. The annotation values can be templated. PrometheusRuleAnnotations
enabled Enable/disable rule. bool
expression The PromQL expression to evaluate. https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated periodically as given by 'interval', and the result recorded as a new set of time series with the metric name as given by 'record'. string (required)
for The amount of time alert must be active before firing. string
labels Labels to add or overwrite before storing the result. PrometheusRuleLabels
record Recorded metrics name. string
resolveConfiguration Defines the configuration for resolving fired alerts. Only relevant for alerts. PrometheusRuleResolveConfiguration
severity The severity of the alerts fired by the rule. Must be between 0 and 4. int

PrometheusRuleAnnotations

Name Description Value

PrometheusRuleGroupAction

Name Description Value
actionGroupId The resource id of the action group to use. string
actionProperties The properties of an action group object. PrometheusRuleGroupActionProperties

PrometheusRuleGroupActionProperties

Name Description Value

PrometheusRuleGroupProperties

Name Description Value
clusterName Apply rule to data from a specific cluster. string
description Rule group description. string
enabled Enable/disable rule group. bool
interval The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and 15 minutes string
rules Defines the rules in the Prometheus rule group. PrometheusRule[] (required)
scopes Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with one scope. This may change in future. string[] (required)

PrometheusRuleLabels

Name Description Value

PrometheusRuleResolveConfiguration

Name Description Value
autoResolved Enable alert auto-resolution. bool
timeToResolve Alert auto-resolution timeout. string

TrackedResourceTags

Name Description Value

Usage Examples

Terraform Samples

A basic example of deploying Alert Management Prometheus Rule Group.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "account" {
  type      = "Microsoft.Monitor/accounts@2023-04-03"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      publicNetworkAccess = "Enabled"
    }

  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "prometheusRuleGroup" {
  type      = "Microsoft.AlertsManagement/prometheusRuleGroups@2023-03-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      clusterName = ""
      description = ""
      enabled     = false
      rules = [
        {
          enabled    = false
          expression = "histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))\n"
          labels = {
            team = "prod"
          }
          record = "job_type:billing_jobs_duration_seconds:99p5m"
        },
      ]
      scopes = [
        azapi_resource.account.id,
      ]
    }

  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}