Last updated: May 29, 2026
Manage Check Rules as Code
Check rules are Dash0 assets that can be versioned and managed as infrastructure as code. This approach enables version control, automated deployment pipelines, consistent configuration across environments, and code review for alert changes.
Dash0 Operator for Kubernetes
Define check rules as PrometheusRule custom resources that sync to Dash0, enabling workflows and native Kubernetes management. Dash0 uses the standard Prometheus Operator format (monitoring.coreos.com/v1), allowing you to reuse existing PrometheusRule definitions without modification.
Example
In the below, the PrometheusRule CRD is used, which is an open source standard. It can be used to design both alert rules (as in the case below), and recording rules.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950apiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata:name: frontend-latencynamespace: monitoringlabels:prometheus: example # any labels you like; used for selecting/organizing the resourcedash0.com/dataset: productionrole: alert-rulesspec:groups:- name: Alertinginterval: 1mrules:- alert: Frontend P99 Latencyexpr: |histogram_quantile(0.99,sum(rate({otel_metric_name="dash0.spans.duration", service_name="frontend"}[5m]))) * 1000 > $__thresholdfor: 2mkeep_firing_for: 1mannotations:# You can interpolate various values in `summary` and `description`summary: "Frontend P99 latency is {{ $value }}ms"description: "P99 latency exceeded threshold for service {{ $labels.service_name }}"# You need to specify threshoilds if your PromQL query in `expr` uses the `$__threshold` symbol.# Threshold values are specified as annotations, so they need to be YAML stringsdash0.com/threshold-degraded: "500"dash0.com/threshold-critical: "500"## These work as well for backwards compatibility# threshold-degraded: "500"# threshold-critical: "1000"# dash0-threshold-degraded: "500"# dash0-threshold-critical: "1000"# optional; "false" to disable this rule without deleting itdash0-enabled: "true"# comma-separated notification channel ids. This is equivalent# to linking the check rule with the notification channels as# you can do via the UIdash0.com/notification-channel-ids: ded5721c-2bf0-4a10-ab33-511fef734b0f,56aaacb2-10c6-4cef-8aeb-d7c862ad863elabels:# Plain check-rule labels. Route by adding filters on these# labels to the notification channels in Dash0 — not# via an annotation on the rule.team: platformservice: frontendseverity: high
The Dash0 Operator for Kubernetes watches for PrometheusRule resources and syncs them to your Dash0 dataset. The dataset to which the PrometheusRule resources are synched is the same defined by the Dash0Monitoring resource in the Kubernetes namespace in which the PrometheusRule resources reside. There are also Dash0-specific annotations for thresholds (dash0-threshold-degraded, dash0-threshold-critical) and notification channels.
Apply and Manage
PrometheusRule resources are synchronized with Dash0 by the Dash0 Operator for Kubernetes provided that:
- You have a
Dash0Monitoringresource in the same namespace as thePrometheusRuleresource - You did not opt-out of the synching through the
synchronizePrometheusRulessetting
For more information, refer to the Managing Dash0 Check Rules documentation of the Dash0 Operator for Kubernetes.
1234567891011121314# Apply the check rulekubectl apply -f check-rule.yaml# List all check ruleskubectl get prometheusrules -n monitoring# View detailskubectl describe prometheusrule frontend-latency -n monitoring# Update the check rulekubectl edit prometheusrule frontend-latency -n monitoring# Delete the check rulekubectl delete prometheusrule frontend-latency -n monitoring
Dash0 Terraform Provider
Manage check rules in your Terraform infrastructure alongside other cloud resources for unified infrastructure management.
Basic Example
The Dash0 Terraform Provider supports both the PrometheusRules CRD format, as well as plain Prometheus alerting rules. But the PrometheusRules CRD format is preferred.
1234567891011121314151617181920212223242526272829303132333435363738394041terraform {required_providers {dash0 = {source = "dash0hq/dash0"version = "~> 1.0"}}}provider "dash0" {api_token = var.dash0_api_tokenendpoint = "https://api.dash0.com"}resource "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}
For related information, see the Dash0 Terraform provider documentation.
Dash0 CLI
Script check rule operations with the Dash0 CLI for automated deployments and batch operations.
The Dash0 CLI supports both the PrometheusRules CRD format, as well as plain Prometheus alerting rules. But the PrometheusRules CRD format is preferred.
Create from File
12# Create a check rule from a YAML filedash0 create-checks create -f check-rule.yaml --dataset <id>
List Check Rules
12# List all check rulesdash0 create-checks list --dataset <id>
Get Check Rule Details
12345# Get a single check rule as YAMLdash0 create-checks get <id> -o yaml --dataset <id># Get check rule in JSON formatdash0 create-checks get <id> -o json --dataset <id>
Update Check Rule
12# Update an existing check ruledash0 create-checks update <id> -f check-rule.yaml --dataset <id>
Delete Check Rule
12# Delete a check ruledash0 create-checks delete <id> --dataset <id>
Further Reading
- Manage Dashboards as Code — Define and manage dashboards using infrastructure as code.
- Manage Views as Code — Manage saved queries as infrastructure as code.
- Manage Synthetic Checks as Code — PrometheusRule CRDs with the Dash0 Operator for Kubernetes, Dash0 Terraform provider resources, and Dash0 CLI commands
- Manage Notification Channels as Code — Manage notification channels using infrastructure as code.