Last updated:
dash0_sampling_rule
Manages a Dash0 Sampling Rule. Sampling rules decide which traces Dash0 keeps: each rule keeps the traces that match its conditions, such as traces with an error span, traces that match an OTTL expression, or a probabilistic share of all traces. See Sample Traces for the condition kinds and their limits.
Creating a sampling rule requires an auth token with the admin role.
spec.enabled is required. The provider always sends a value for it, so an omitted field would silently create a disabled rule and later switch off one enabled elsewhere.
Changing dataset destroys the rule and re-creates it under a new origin.
Example Usage
resource "dash0_sampling_rule" "keep_production_errors" {
dataset = "default"
sampling_rule_yaml = file("${path.module}/sampling_rule.yaml")
}Schema
Required
sampling_rule_yaml(String) The sampling rule definition in YAML format. The YAML must declarekind: Dash0Sampling, an explicitspec.enabled, andspec.conditions, a tree ofprobabilistic,ottl,errorandandconditions.spec.display.nameandspec.rateLimitare optional.metadata.labels.customholds your own labels and is covered by drift detection. The othermetadata.labelskeys are server-managed and ignored.
Optional
dataset(String) The identifier of the Dash0 dataset that the sampling 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 under a new origin.
Read-Only
id(String) The server-assigned identifier of the sampling rule, resolved by the provider after creation.origin(String) A unique identifier for the sampling rule, automatically generated on creation. Used to reference the rule for updates, reads, deletes, and imports.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
#!/bin/bash
terraform import dash0_sampling_rule.keep_production_errors default,tf_existing-sampling-rule-origin