azurerm_monitor_alert_prometheus_rule_group

Manages an Alert Management Prometheus Rule Group.

Example Usage

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_monitor_action_group" "example" {
  name                = "example-mag"
  resource_group_name = azurerm_resource_group.example.name
  short_name          = "testag"
}

resource "azurerm_monitor_workspace" "example" {
  name                = "example-amw"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_kubernetes_cluster" "example" {
  name                = "example-cluster"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  dns_prefix          = "example-aks"

  default_node_pool {
    name                   = "default"
    node_count             = 1
    vm_size                = "Standard_DS2_v2"
    enable_host_encryption = true
  }

  identity {
    type = "SystemAssigned"
  }
}

resource "azurerm_monitor_alert_prometheus_rule_group" "example" {
  name                = "example-amprg"
  location            = "West Europe"
  resource_group_name = azurerm_resource_group.example.name
  cluster_name        = azurerm_kubernetes_cluster.example.name
  description         = "This is the description of the following rule group"
  rule_group_enabled  = false
  interval            = "PT1M"
  scopes              = [azurerm_monitor_workspace.example.id]
  rule {
    enabled    = false
    expression = <<EOF
histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service="billing-processing"}[5m])) by (job_type))
EOF
    record     = "job_type:billing_jobs_duration_seconds:99p5m"
    labels = {
      team = "prod"
    }
  }

  rule {
    alert      = "Billing_Processing_Very_Slow"
    enabled    = true
    expression = <<EOF
histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service="billing-processing"}[5m])) by (job_type))
EOF
    for        = "PT5M"
    severity   = 2

    action {
      action_group_id = azurerm_monitor_action_group.example.id
    }

    alert_resolution {
      auto_resolved   = true
      time_to_resolve = "PT10M"
    }

    annotations = {
      annotationName = "annotationValue"
    }

    labels = {
      team = "prod"
    }
  }
  tags = {
    key = "value"
  }
}

Arguments Reference

The following arguments are supported:


A rule block supports the following:


An action block supports the following:


An alert_resolution block supports the following:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Alert Management Prometheus Rule Group can be imported using the resource id, e.g.

terraform import azurerm_monitor_alert_prometheus_rule_group.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AlertsManagement/prometheusRuleGroups/ruleGroup1