Last updated:
dash0_recording_rule
Terraform resource for Dash0 recording rule groups defined in the Prometheus Rule format.
Manages a Dash0 Recording Rule. Recording rules pre-compute frequently needed or computationally expensive PromQL expressions and save the results as new time series. See Manage Check Rules as Code for more details — recording rules share the same Prometheus rule format and management surface as alert check rules. The recording rule definition uses the Prometheus Rule format.
Example Usage
terraform
resource "dash0_recording_rule" "span_duration_p95" {
dataset = "production"
recording_rule_yaml = <<-EOF
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: span-duration-aggregations
spec:
groups:
- name: SpanDurationAggregations
interval: 1m0s
rules:
- record: service_name:dash0_spans_duration:p95_5m
expr: histogram_quantile(0.95, sum by (le, service_name) (rate({otel_metric_name="dash0.spans.duration"}[5m])))
labels:
quantile: "0.95"
EOF
}Schema
Required
recording_rule_yaml(String) The recording rule definition in YAML format, following the Prometheus recording rule specification.
Optional
dataset(String) The identifier of the Dash0 dataset that the recording 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. If omitted, the provider-leveldatasetdefault is used (see the provider'sdatasetattribute). Changing this value forces the resource to be recreated.
Read-Only
id(String) The server-assigned identifier of the recording rule group, resolved by the provider after creation. The value has the formrecording_rule_group_<ulid>(a ULID, not a UUID) because recording rules live inside groups and the API addresses the whole group. Recording rules are not addressable in the Dash0 web app, so nourlis exposed.origin(String) A unique identifier for the recording rule, automatically generated on creation. Used to reference the recording rule for updates, reads, deletes, and imports.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
shell
#!/bin/bash
terraform import dash0_recording_rule.span_duration_p95 production,tf_existing-recording-rule-origin