Alert Management - Prometheus Rule Groups

Overview

The Prometheus Rule Group builder is used to create prometheus rule groups which can then be applied to Prometheus metrics in an Azure Monitor workspace.

  • Prometheus Rule Groups (Microsoft.AlertsManagement/prometheusRuleGroups)

Prometheus Rule Group Builder Keywords

The Prometheus Rule Group builder (prometheusRuleGroup) constructs prometheus rule groups.

KeywordPurpose
nameSets the name of the Prometheus Rule Group.
descriptionSpecifies the description of the Prometheus Rule Group.
cluster_nameSpecifies the name of the AKS cluster associated with this rule group.
intervalSpecifies the interval to run the Prometheus rule group in ISO 8601 duration format.
add_rulesAdds rules to the Prometheus rule group. At least one rule is required.
enable_rule_groupEnables the rule group.
disable_rule_groupDisables the rule group.
azure_monitor_workspace_idSpecifies the Azure monitor workspace id. This is required.
scopesSpecifies the scopes for the Prometheus rule groups. Will at least contain the azure_monitor_workspace_id by default.

Prometheus Rule Builder

The Prometheus Rule builder (prometheusRule) creates Prometheus Rule for the Prometheus Rule Group.

KeywordPurpose
recordSpecifies recorded metrics name for Prometheus Rule.
expressionSpecifies a PromQL expression to evaluate. This is required
labelsSpecifies labels to add or overwrite before storing the result.
enable_ruleEnables the Prometheus rule.
disable_ruleDisables the Prometheus rule.
alertSets the alert rule name for Prometheus Rule.
severitySpecifies the severity of alerts fired by Prometheus Rule.
actionsSpecifies actions that are performed when the alert rule becomes active.
resolve_configurationDefines configuration for resolving alerts
set_forSpecifies how long the alert should be active before firing.

Basic Example

The simplest Prometheus Rule group requires at least one rule and specify azure_monitor_workspace_id

open Farmer
open Farmer.Builders
open Farmer.Arm.AlertsManagement

let myRule = prometheusRule {
        expression "up == 1"
    }

let monitoringAccountType =
    ResourceType("Microsoft.Monitor/accounts", "2025-05-03-preview")

let monitorAccountId =
    ResourceId.create (monitoringAccountType, ResourceName "monitorAccount")

let myGroup = prometheusRuleGroup {
    name "myGroup"
    add_rules [ myRule ]
    azure_monitor_workspace_id monitorAccountId
}