Last updated: July 19, 2026
dash0_check_rule
Terraform resource for Dash0 check rules — PromQL-based alerting conditions defined in the Prometheus Rule format.
Manages a Dash0 Check Rule. Check rules define alerting conditions based on PromQL expressions that are continuously evaluated against your telemetry data. See About Alerting and About Creating Check Rules for more details. The check rule definition uses the Prometheus Rule format.
More information on how Prometheus rules are mapped to Dash0 check rules can be found in the Dash0 Operator documentation.
Example Usage
terraform
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899resource "dash0_check_rule" "adservice_error_rate" {dataset = "production"# Currently only one group incl. one rule is supportedcheck_rule_yaml = <<-EOFapiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata:name: adservicespec:groups:- name: Alertinginterval: 1m0srules:- alert: adserviceexpr: (sum by (service_namespace, service_name) (increase({otel_metric_name = "dash0.spans", service_name = "adservice", service_namespace = "opentelemetry-demo", dash0_operation_name != "", otel_span_status_code = "ERROR"}[5m]))) / (sum by (service_namespace, service_name) (increase({otel_metric_name = "dash0.spans", service_name = "adservice", service_namespace = "opentelemetry-demo", dash0_operation_name != ""}[5m])) > 0)*100 > $__thresholdfor: 0skeep_firing_for: 0sannotations:summary: 'High error percentage for adservice: {{$value|printf "%.2f"}}%'description: 'High error percentage for adservice: {{$value|printf "%.2f"}}%'dash0-threshold-critical: "40"dash0-threshold-degraded: "35"dash0-enabled: truelabels: {}EOF}# Fanning out check rules with `for_each` and routing each rule's alerts to one# or more notification channels through the `dash0.com/notification-channel-ids`# annotation. The annotation takes a comma-separated list of channel UUIDs —# the `id` attribute on `dash0_notification_channel`, not the `origin`.resource "dash0_notification_channel" "team_oncall" {for_each = {backend = "backend-oncall@example.com"frontend = "frontend-oncall@example.com"sre = "sre-oncall@example.com"}notification_channel_yaml = <<-YAMLkind: Dash0NotificationChannelmetadata:name: ${each.key} on-callspec:type: email_v2config:recipients:- ${each.value}plaintext: falsefrequency: 10mYAML}locals {service_check_rules = {backend-api = {service = "backend-api"channels = ["backend", "sre"]}frontend-web = {service = "frontend-web"channels = ["frontend"]}checkout = {service = "checkout"channels = ["backend", "sre"]}}}resource "dash0_check_rule" "service_error_rate" {for_each = local.service_check_rulesdataset = "production"check_rule_yaml = <<-EOFapiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata:name: ${each.key}-error-rateannotations:dash0.com/notification-channel-ids: ${join(",", [for c in each.value.channels : dash0_notification_channel.team_oncall[c].id])}spec:groups:- name: Alertinginterval: 1m0srules:- alert: ${each.value.service}-error-rateexpr: (sum by (service_name) (increase({otel_metric_name = "dash0.spans", service_name = "${each.value.service}", otel_span_status_code = "ERROR"}[5m]))) / (sum by (service_name) (increase({otel_metric_name = "dash0.spans", service_name = "${each.value.service}"}[5m])) > 0)*100 > $__thresholdfor: 0skeep_firing_for: 0sannotations:summary: 'High error percentage for ${each.value.service}: {{$value|printf "%.2f"}}%'dash0-threshold-critical: "40"dash0-threshold-degraded: "35"dash0-enabled: truelabels: {}EOF}
Schema
Required
check_rule_yaml(String) The check rule definition in YAML format, following the Prometheus alerting rule specification. Thedash0.com/sharingmetadata annotation is supported to control sharing settings; changes to it trigger a resource update. All other metadata annotations are managed by the server and ignored during drift detection.dataset(String) The identifier of the Dash0 dataset that the check rule belongs to. Provide the dataset's identifier, which is immutable, not the 'name'. Datasets are used to separate observability data within a Dash0 organization. Changing this value forces the resource to be recreated.
Read-Only
id(String) The server-assigned identifier of the check rule, resolved by the provider after creation. The Dash0 check-rules API addresses rules by their origin, so for this resourceidequalsorigin(thetf_-prefixed value generated by the provider) — unlike dashboards, views, synthetic checks, and notification channels, whereidis a distinct server-assigned UUID. The attribute is exposed for symmetry across resources; reference it when wiring the check rule's identifier into another resource.origin(String) A unique identifier for the check rule, automatically generated on creation. Used to reference the check rule for updates, reads, deletes, and imports.url(String) The URL to open this check rule in the Dash0 web app, derived from the Dash0 API URL and the check rule's server-assigned identifier. Computed by the provider after creation. May be empty if the app URL cannot be derived (e.g. for self-hosted deployments with a custom web app domain).
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
shell
12#!/bin/bashterraform import dash0_check_rule.adservice_error_rate production,tf_existing-check-rule-origin