dash0_spam_filter

Terraform resource for Dash0 spam filters that drop matching telemetry before ingestion.

Manages a Dash0 Spam Filter. Spam filters allow you to drop noisy or unwanted telemetry data before it is stored, reducing costs and improving signal-to-noise ratio. Filters are scoped to a dataset and can target logs, spans, metric data points, web events, or profile samples.

To switch a filter off without deleting it, set the dash0.com/enabled annotation to "false". A filter that omits the annotation is enabled, so Terraform switches it back on if it was disabled outside Terraform.

See Set Spam Filters for more details.

Example Usage

resource "dash0_spam_filter" "drop_health_checks" {
  dataset = "default"

  spam_filter_yaml = <<-EOF
apiVersion: v1alpha1
kind: Dash0SpamFilter
metadata:
  name: Drop noisy health checks
spec:
  contexts:
    - log
  filter:
    - key: "k8s.namespace.name"
      operator: "is"
      value: "kube-system"
EOF
}

# v1alpha2 uses a single `context` instead of a `contexts` list.
resource "dash0_spam_filter" "drop_debug_logs" {
  dataset = "default"

  spam_filter_yaml = <<-EOF
apiVersion: v1alpha2
kind: Dash0SpamFilter
metadata:
  name: Drop debug logs
spec:
  context: log
  filter:
    - key: "severity_text"
      operator: "is"
      value: "DEBUG"
EOF
}

# Set dash0.com/enabled to "false" to keep a filter but stop it from dropping data.
resource "dash0_spam_filter" "paused_filter" {
  dataset = "default"

  spam_filter_yaml = <<-EOF
apiVersion: v1alpha2
kind: Dash0SpamFilter
metadata:
  name: Drop synthetic traffic
  annotations:
    dash0.com/enabled: "false"
spec:
  context: span
  filter:
    - key: "user_agent.original"
      operator: "contains"
      value: "synthetic-monitor"
EOF
}

Schema

Required

  • spam_filter_yaml (String) The spam filter definition in YAML format. The YAML must include a metadata.name field and a spec with a filter (list of key-value matchers) and either contexts (v1alpha1, a list holding exactly one signal type) or context (v1alpha2, a single signal type). The signal type is one of log, span, datapoint, web_event or profile_sample. The apiVersion field determines which shape is expected. The optional metadata.annotations key dash0.com/enabled takes the quoted string "true" (the default) or "false". metadata.labels is not covered by drift detection.

Optional

  • dataset (String) The identifier of the Dash0 dataset that the spam filter 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-level dataset default is used (see the provider's dataset attribute). Changing this value forces the resource to be recreated.

Read-Only

  • id (String) The server-assigned UUID of the spam filter, resolved by the provider after creation. Useful for cross-referencing the filter from other resources or external systems. Spam filters are not addressable in the Dash0 web app, so no url is exposed.
  • origin (String) A unique identifier for the spam filter, automatically generated on creation. Used to reference the spam filter 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_spam_filter.drop_health_checks default,tf_existing-spam-filter-origin

Last updated: