### Build the Provider Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CONTRIBUTING.md Run this command to build the provider binary. Ensure Go and Terraform are installed and meet the version requirements. ```shell make build ``` -------------------------------- ### Install Lychee Binary Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Installs the lychee binary on demand into the .tools/lychee directory. It prioritizes using an existing lychee binary on the PATH. ```bash make lint-links-install ``` -------------------------------- ### Install Provider Locally Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CONTRIBUTING.md Execute this command to install the provider into your local Terraform plugin directory for development and testing purposes. ```shell make install ``` -------------------------------- ### Configure Local Terraform Installation Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CONTRIBUTING.md Update your `~/.terraformrc` file to point to the locally installed provider mirror. Replace `{{USER_NAME}}` with your actual username. ```terraform provider_installation { filesystem_mirror { path = "/Users/{{USER_NAME}}/terraform-provider-mirror" } } ``` -------------------------------- ### Import a Dash0 Dashboard Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/dashboard.md This example shows how to import an existing Dash0 dashboard into Terraform management. You need to provide the dataset and the dashboard's ID or origin. ```bash #!/bin/bash terraform import dash0_dashboard.name "{{ dataset }},{{ id_or_origin }}" ``` -------------------------------- ### Import an existing Spam Filter Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/spam_filter.md This example shows how to import an existing spam filter using the `terraform import` command. Ensure you provide the correct dataset and filter origin. ```bash #!/bin/bash terraform import dash0_spam_filter.drop_health_checks default,tf_existing-spam-filter-origin ``` -------------------------------- ### Import Notification Channel Example Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Use this command to import an existing notification channel into your Terraform state. Replace '{{ id_or_origin }}' with the actual ID or origin of the notification channel. ```shell #!/bin/bash terraform import dash0_notification_channel.name "{{ id_or_origin }}" ``` -------------------------------- ### Create Service-Specific Check Rules with Routing Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/check_rule.md This example demonstrates creating multiple `dash0_check_rule` resources dynamically using `for_each` based on a local variable. It routes alerts for each service to one or more notification channels specified in the `dash0.com/notification-channel-ids` annotation. ```terraform 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_rules dataset = "production" check_rule_yaml = <<-EOF apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: ${each.key}-error-rate annotations: dash0.com/notification-channel-ids: ${join(",", [for c in each.value.channels : dash0_notification_channel.team_oncall[c].id])} spec: groups: - name: Alerting interval: 1m0s rules: - alert: ${each.value.service}-error-rate expr: (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 > $__threshold for: 0s keep_firing_for: 0s annotations: summary: 'High error percentage for ${each.value.service}: {{$value|printf "%.2f"}}%' dash0-threshold-critical: "40" dash0-threshold-degraded: "35" dash0-enabled: true labels: {} EOF } ``` -------------------------------- ### Importing a Synthetic Check Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/synthetic_check.md This example shows the bash command to import an existing synthetic check resource into your Terraform state. You need to provide the dataset and either the ID or origin of the check. ```bash #!/bin/bash terraform import dash0_synthetic_check.name "{{ dataset }},{{ id_or_origin }}" ``` -------------------------------- ### Create a Spam Filter (v1alpha1) Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/spam_filter.md Use this example to create a spam filter using the `v1alpha1` API version. This version uses a `contexts` list to specify signal types. ```terraform 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 } ``` -------------------------------- ### Fan Out Check Rules to Notification Channels Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md This example demonstrates how to create multiple check rules dynamically using `for_each` and route their alerts to specific notification channels. It uses a local variable to define services and their associated channels, then references the `dash0_notification_channel` resource IDs. ```terraform 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_rules dataset = "production" check_rule_yaml = <<-EOF apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: ${each.key}-error-rate annotations: dash0.com/notification-channel-ids: ${join(",", [for c in each.value.channels : dash0_notification_channel.team_oncall[c].id])} spec: groups: - name: Alerting interval: 1m0s rules: - alert: ${each.value.service}-error-rate expr: (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 > $__threshold for: 0s keep_firing_for: 0s annotations: summary: 'High error percentage for ${each.value.service}: {{$value|printf "%.2f"}}%' dash0-threshold-critical: "40" dash0-threshold-degraded: "35" dash0-enabled: true labels: {} EOF } ``` -------------------------------- ### Create a Spam Filter (v1alpha2) Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/spam_filter.md Use this example to create a spam filter using the `v1alpha2` API version. This version uses a single `context` field instead of a `contexts` list. ```terraform # 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 } ``` -------------------------------- ### Synthetic Check with Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/synthetic_check.md This example demonstrates creating a synthetic check that is linked to a notification channel. It uses `for_each` to create multiple notification channels and then references one of them by its computed `id`. ```terraform 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 = <<-YAML kind: Dash0NotificationChannel metadata: name: ${each.key} on-call spec: type: email_v2 config: recipients: - ${each.value} plaintext: false frequency: 10m YAML } resource "dash0_synthetic_check" "checkout_api" { dataset = "default" synthetic_check_yaml = <<-YAML kind: Dash0SyntheticCheck metadata: name: checkout-api spec: enabled: true notifications: channels: - ${dash0_notification_channel.team_oncall["sre"].id} plugin: display: name: checkout-api kind: http spec: assertions: criticalAssertions: - kind: status_code spec: value: "200" operator: is request: method: get url: https://api.example.com/health queryParameters: [] headers: [] redirects: follow tls: allowInsecure: false tracing: addTracingHeaders: true retries: kind: fixed spec: attempts: 3 delay: 1s schedule: interval: 1m locations: - de-frankfurt - us-oregon strategy: all_locations YAML } ``` -------------------------------- ### Create a Git Tag for Release Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CONTRIBUTING.md Tag a new release version using `vX.X.X` format and push the tag to the origin repository. ```shell git tag -a vX.X.X -m vX.X.X git push origin --tags ``` -------------------------------- ### Build Project Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Verifies that the project compiles successfully. ```bash make build ``` -------------------------------- ### Build Commands for terraform-provider-dash0 Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Common make commands for building, testing, and managing the terraform-provider-dash0 project. ```bash make build ``` ```bash make test ``` ```bash go test -v github.com/dash0hq/terraform-provider-dash0/internal/provider -run TestName ``` ```bash make testacc ``` ```bash make docs ``` ```bash make clean ``` ```bash make install ``` -------------------------------- ### Lint Project Files Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Runs Go, shell, and link linters to identify and fix issues in the codebase. ```bash make lint ``` -------------------------------- ### Preview Changelog Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md This command generates a preview of the CHANGELOG.md file to review your entries before release. ```bash make chlog-preview ``` -------------------------------- ### Run Unit Tests Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Executes all defined unit tests for the project. ```bash make test-unit ``` -------------------------------- ### Run All Validation Steps Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Execute all project validation steps, including build, linting, and unit/roundtrip tests. This is a mandatory step before considering a change complete. ```bash make all ``` -------------------------------- ### Verify Canonical URL with MCP Search Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Use the `mcp__dash0-prod__searchKnowledgeBase` tool to find the authoritative URL for Dash0 documentation. Always use the URL returned by this tool verbatim. ```bash mcp__dash0-prod__searchKnowledgeBase("terms describing the destination page") ``` -------------------------------- ### Configure Terraform with Dash0 Provider and CLI Profile Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Specify the Dash0 provider and optionally a named dash0 CLI profile for authentication. Omit `profile` to use the CLI's active profile. ```terraform terraform { required_providers { dash0 = { source = "dash0hq/dash0" version = ">~ 1.6.0" } } } # The `profile` attribute loads credentials from a named dash0 CLI profile # (configured via `dash0 config profiles create`). Omit it to fall back to the # CLI's active profile. provider "dash0" { profile = "test1" } ``` -------------------------------- ### Create a Basic Check Rule Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/check_rule.md This snippet demonstrates how to create a single `dash0_check_rule` resource for the 'adservice' to monitor its error rate. It includes a basic Prometheus Rule definition within the `check_rule_yaml`. ```terraform resource "dash0_check_rule" "adservice_error_rate" { dataset = "production" # Currently only one group incl. one rule is supported check_rule_yaml = <<-EOF apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: adservice spec: groups: - name: Alerting interval: 1m0s rules: - alert: adservice expr: (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 > $__threshold for: 0s keep_firing_for: 0s annotations: 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: true labels: {} EOF } ``` -------------------------------- ### Import an Existing Recording Rule Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/recording_rule.md Imports an existing Dash0 recording rule into Terraform management. The import command requires the Terraform resource name and the dataset and origin identifier of the recording rule. ```bash #!/bin/bash terraform import dash0_recording_rule.span_duration_p95 production,tf_existing-recording-rule-origin ``` -------------------------------- ### Run Roundtrip Tests Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Executes Dockerized roundtrip tests against the real Dash0 API to catch integration issues. ```bash make test-roundtrip ``` -------------------------------- ### Set Environment Variables for Dash0 Provider Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure authentication credentials using environment variables. `DASH0_API_URL` and `DASH0_AUTH_TOKEN` are required. `DASH0_MAX_RETRIES` is optional. ```sh export DASH0_API_URL="https://api.us-west-2.aws.dash0.com" export DASH0_AUTH_TOKEN="auth_xxxx" export DASH0_MAX_RETRIES=3 # optional, default: 3, max: 5 ``` -------------------------------- ### Run Roundtrip Tests for terraform-provider-dash0 Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Commands to execute roundtrip tests, which verify Terraform resource types against the Dash0 API. Ensure Docker is running and the dash0 CLI is configured, or set necessary environment variables. ```bash make test-roundtrip ``` ```bash ./test/roundtrip/run_all.sh test_dashboard.sh ``` -------------------------------- ### Import a Dash0 View Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/view.md Import an existing Dash0 view into Terraform management. The import command requires the dataset identifier and either the view's ID or origin. ```bash #!/bin/bash terraform import dash0_view.name "{{ dataset }},{{ id_or_origin }}" ``` -------------------------------- ### Create a Dash0 View Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/view.md Use this resource to create a new Dash0 view. The `view_yaml` argument accepts a file path to a YAML definition of the view. ```terraform resource "dash0_view" "my_check" { dataset = "default" view_yaml = file("${path.module}/view.yaml") } ``` -------------------------------- ### Create New Changelog Entry Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Use this command to create a new YAML file for a changelog entry, named after the current branch. ```bash make chlog-new ``` -------------------------------- ### Prefix Logging with Context in Go Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Prefix all log messages with context using `tflog` to ensure clarity and traceability. This helps in identifying the source of log entries during runtime. ```go tflog.Debug(ctx, "message") ``` -------------------------------- ### Create a Dash0 Dashboard Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/dashboard.md Use this snippet to create a new Dash0 dashboard. It requires specifying the dataset and providing the dashboard definition in YAML format, typically loaded from a file. ```terraform resource "dash0_dashboard" "my_dashboard" { dataset = "default" dashboard_yaml = file("${path.module}/dashboard.yaml") } ``` -------------------------------- ### Load Notification Channel YAML from File Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Load the notification channel configuration from an external YAML file using the `file()` function. ```terraform # You can also load the YAML definition from a file: # # resource "dash0_notification_channel" "from_file" { # notification_channel_yaml = file("${path.module}/notification_channel.yaml") # } ``` -------------------------------- ### Create a Recording Rule Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/recording_rule.md Defines a Dash0 recording rule using Terraform. The `recording_rule_yaml` field accepts a string containing the PrometheusRule definition. ```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 } ``` -------------------------------- ### Configure Slack Webhook Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Set up a Slack webhook for receiving alerts. Ensure the webhook URL and channel are correctly configured. ```terraform # Slack webhook notification channel resource "dash0_notification_channel" "slack_webhook" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Slack Alerts spec: type: slack config: webhookURL: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" channel: "#alerts" frequency: 10m YAML } ``` -------------------------------- ### Configure Dash0 Provider in Terraform Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Set authentication credentials directly within the Terraform provider block. Environment variables take precedence. ```terraform provider "dash0" { url = "https://api.us-west-2.aws.dash0.com" auth_token = "auth_xxxx" max_retries = 3 # optional, default: 3, max: 5 } ``` -------------------------------- ### Configure OpsGenie Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Set up an OpsGenie notification channel. Provide your OpsGenie API key and instance region. ```terraform # OpsGenie notification channel resource "dash0_notification_channel" "opsgenie" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Opsgenie Alerts spec: type: opsgenie config: apiKey: "my-opsgenie-api-key" instance: us frequency: 10m YAML } ``` -------------------------------- ### Validate Changelog Entries Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Run this command to validate the format and content of your changelog entries. ```bash make chlog-validate ``` -------------------------------- ### Basic Synthetic Check Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/synthetic_check.md This snippet shows how to create a basic synthetic check by referencing a YAML file for its configuration. ```terraform resource "dash0_synthetic_check" "my_check" { dataset = "default" synthetic_check_yaml = file("${path.module}/synthetic_check.yaml") } ``` -------------------------------- ### Import Dash0 Check Rule Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/check_rule.md Use this command to import an existing Dash0 check rule into your Terraform state. Replace `production,tf_existing-check-rule-origin` with the actual rule ID and name. ```shell #!/bin/bash terraform import dash0_check_rule.adservice_error_rate production,tf_existing-check-rule-origin ``` -------------------------------- ### Configure Email Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Set up an email notification channel. Specify recipients and whether to send plain text emails. ```terraform # Email notification channel resource "dash0_notification_channel" "email" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Email Alerts spec: type: email_v2 config: recipients: - oncall@example.com - sre-team@example.com plaintext: false frequency: 10m YAML } ``` -------------------------------- ### Define Notification Channels Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/check_rule.md This snippet shows how to define multiple `dash0_notification_channel` resources using `for_each`. Each channel is configured for email delivery to different on-call recipients. ```terraform 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 = <<-YAML kind: Dash0NotificationChannel metadata: name: ${each.key} on-call spec: type: email_v2 config: recipients: - ${each.value} plaintext: false frequency: 10m YAML } ``` -------------------------------- ### Configure Dash0 Provider with Environment Variables Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure the Dash0 provider by setting environment variables for the API URL and authentication token. This is useful for keeping credentials out of your Terraform configuration files. ```terraform terraform { required_providers { dash0 = { source = "dash0hq/dash0" version = ">~1.6.0" } } } provider "dash0" { # Configuration will be read from environment variables: # DASH0_API_URL (or DASH0_URL as fallback) and DASH0_AUTH_TOKEN } ``` -------------------------------- ### Configure Dash0 Provider with Direct Configuration Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure the Dash0 provider directly within your Terraform configuration by specifying the URL and authentication token. Use this when you prefer to manage credentials within your Terraform files. ```terraform terraform { required_providers { dash0 = { source = "dash0hq/dash0" version = ">~1.6.0" } } } provider "dash0" { url = "https://api.us-west-2.aws.dash0.com" auth_token = "auth_xxxx" } ``` -------------------------------- ### Handle Errors with Context in Go Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md When handling errors in Go, wrap them with `fmt.Errorf` to provide additional context and preserve the original error. This is crucial for effective debugging. ```go fmt.Errorf("message: %w", err) ``` -------------------------------- ### Configure Webhook with Routing Rules Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure a webhook notification channel with routing rules to filter alerts. Alerts are sent based on specified conditions. ```terraform # Webhook notification channel with routing rules # # Routing rules control which alerts are delivered to this channel. # Each top-level list item is an OR group; conditions within a group are ANDed. # In this example, notifications are sent when: # (team.name = "sre" AND deployment.environment.name = "production") # OR (service.severity = "critical") resource "dash0_notification_channel" "webhook_with_routing" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Production Alerts (Webhook with Routing) spec: type: webhook config: url: "https://example.com/webhook/production-alerts" frequency: 5m routing: filters: - - key: team.name operator: is value: sre - key: deployment.environment.name operator: is value: production - - key: service.severity operator: is value: critical YAML } ``` -------------------------------- ### Configure Generic Webhook Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure a generic webhook for receiving alerts. Specify the URL where alerts should be sent. ```terraform # Generic webhook notification channel resource "dash0_notification_channel" "webhook" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Webhook Alerts spec: type: webhook config: url: "https://example.com/webhook/alerts" frequency: 10m YAML } ``` -------------------------------- ### Configure Slack Bot Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure a Slack bot notification channel. This requires authorizing the Dash0 Slack App and inviting the bot to the desired channels. ```terraform # Slack Bot notification channel # # Prerequisites: # 1. Install the Dash0 Slack App via the Dash0 UI (Settings > Notification # Channels > Add Notification Channel > Slack Bot > Authorize). This is a # one-time operation per Slack workspace. # 2. Invite the bot to the target channel: /invite @Dash0 # 3. The Dash0 bot must be explicitly added to each Slack channel it will post to. # In Slack, open the target channel and run `/invite @Dash0`. Repeat this for every channel # you want to receive notifications in. resource "dash0_notification_channel" "slack_bot" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Slack Bot Alerts spec: type: slack_bot config: teamId: "T012345" channel: "#alerts" frequency: 10m YAML } ``` -------------------------------- ### Configure Google Chat Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Set up a Google Chat webhook for alerts. Provide the correct webhook URL for your Google Chat space. ```terraform # Google Chat notification channel resource "dash0_notification_channel" "google_chat" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Google Chat Alerts spec: type: google_chat_webhook config: url: "https://chat.googleapis.com/v1/spaces/.../messages?key=..." frequency: 10m YAML } ``` -------------------------------- ### Slack Bot Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Set up a Slack notification channel using the Slack Bot integration. This requires authorizing the Dash0 Slack App and inviting the bot to the target channels. ```terraform resource "dash0_notification_channel" "slack_bot" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Slack Bot Alerts spec: type: slack_bot config: teamId: "T012345" channel: "#alerts" frequency: 10m YAML } ``` -------------------------------- ### OpsGenie Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Configure OpsGenie for alert management. Requires an API key and the OpsGenie instance URL. ```terraform resource "dash0_notification_channel" "opsgenie" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Opsgenie Alerts spec: type: opsgenie config: apiKey: "my-opsgenie-api-key" instance: us frequency: 10m YAML } ``` -------------------------------- ### Discord Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Set up Discord notifications by providing a webhook URL. Alerts will be posted to the specified Discord channel. ```terraform resource "dash0_notification_channel" "discord" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Discord Alerts spec: type: discord_webhook config: url: "https://discord.com/api/webhooks/..." frequency: 10m YAML } ``` -------------------------------- ### Configure Discord Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure a Discord webhook for receiving alerts. Ensure the webhook URL is correctly specified. ```terraform # Discord notification channel resource "dash0_notification_channel" "discord" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Discord Alerts spec: type: discord_webhook config: url: "https://discord.com/api/webhooks/..." frequency: 10m YAML } ``` -------------------------------- ### Define a Single Check Rule Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md This snippet defines a single Dash0 check rule for the 'adservice' to monitor its error rate. It uses a PrometheusRule resource with a specific expression and annotations for thresholds and notifications. ```terraform resource "dash0_check_rule" "adservice_error_rate" { dataset = "production" # Currently only one group incl. one rule is supported check_rule_yaml = <<-EOF apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: adservice spec: groups: - name: Alerting interval: 1m0s rules: - alert: adservice expr: (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 > $__threshold for: 0s keep_firing_for: 0s annotations: 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: true labels: {} EOF } ``` -------------------------------- ### Validate Links with Lychee Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md Runs the lychee tool to check for broken links across various project files. Network access is required for this operation. ```bash make lint-links ``` -------------------------------- ### Configure Notification Channels Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md This snippet defines multiple email notification channels using Terraform's `for_each` loop. Each channel is configured with a specific recipient email address. ```terraform 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 = <<-YAML kind: Dash0NotificationChannel metadata: name: ${each.key} on-call spec: type: email_v2 config: recipients: - ${each.value} plaintext: false frequency: 10m YAML } ``` -------------------------------- ### Configure PagerDuty Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Configure a PagerDuty notification channel. Requires a PagerDuty integration key and the events API URL. ```terraform # PagerDuty notification channel resource "dash0_notification_channel" "pagerduty" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: PagerDuty Incidents spec: type: pagerduty config: key: "my-pagerduty-integration-key" url: "https://events.pagerduty.com/v2/enqueue" frequency: 10m YAML } ``` -------------------------------- ### Webhook Notification Channel with Routing Rules Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Configure a webhook notification channel with advanced routing rules. This allows selective delivery of alerts based on defined conditions. ```terraform resource "dash0_notification_channel" "webhook_with_routing" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Production Alerts (Webhook with Routing) spec: type: webhook config: url: "https://example.com/webhook/production-alerts" frequency: 5m routing: filters: - - key: team.name operator: is value: sre - key: deployment.environment.name operator: is value: production - - key: service.severity operator: is value: critical YAML } ``` -------------------------------- ### Generate Origin with tf_ Prefix and UUID Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/CLAUDE.md The provider generates a unique origin for resources with a 'tf_' prefix and a UUID. This is stored as a computed attribute in Terraform state. ```go origin = "tf_" + uuid.New().String() ``` -------------------------------- ### PagerDuty Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Integrate with PagerDuty to create incidents for alerts. Requires a PagerDuty integration key and the events API URL. ```terraform resource "dash0_notification_channel" "pagerduty" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: PagerDuty Incidents spec: type: pagerduty config: key: "my-pagerduty-integration-key" url: "https://events.pagerduty.com/v2/enqueue" frequency: 10m YAML } ``` -------------------------------- ### Manage a Dash0 Synthetic Check Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/index.md Define and manage a Dash0 synthetic check using a YAML configuration. This snippet shows basic configuration for a synthetic check, including its dataset and YAML definition. ```terraform resource "dash0_synthetic_check" "my_check" { dataset = "default" synthetic_check_yaml = file("${path.module}/synthetic_check.yaml") } # Creating notification channels with `for_each`, and linking one of them # from a synthetic check. # # `dash0_notification_channel` exposes a computed `id` attribute (the # server-assigned UUID, resolved by the provider after creation). The # synthetic check references that id in `spec.notifications.channels`, # which requires raw UUIDs rather than the `tf_`-prefixed 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 = <<-YAML kind: Dash0NotificationChannel metadata: name: ${each.key} on-call spec: type: email_v2 config: recipients: - ${each.value} plaintext: false frequency: 10m YAML } resource "dash0_synthetic_check" "checkout_api" { dataset = "default" synthetic_check_yaml = <<-YAML kind: Dash0SyntheticCheck metadata: name: checkout-api spec: enabled: true notifications: channels: - ${dash0_notification_channel.team_oncall["sre"].id} plugin: display: name: checkout-api kind: http spec: assertions: criticalAssertions: - kind: status_code spec: value: "200" operator: is request: method: get url: https://api.example.com/health queryParameters: [] headers: [] redirects: follow tls: allowInsecure: false tracing: addTracingHeaders: true retries: kind: fixed spec: attempts: 3 delay: 1s schedule: interval: 1m locations: - de-frankfurt - us-oregon strategy: all_locations YAML } ``` -------------------------------- ### Generic Webhook Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Send alerts to a generic webhook endpoint. Specify the URL where the alerts should be posted. ```terraform resource "dash0_notification_channel" "webhook" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Webhook Alerts spec: type: webhook config: url: "https://example.com/webhook/alerts" frequency: 10m YAML } ``` -------------------------------- ### Slack Webhook Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Configure a Slack notification channel using a webhook URL. This is suitable for sending alerts directly to a Slack channel via its incoming webhook. ```terraform resource "dash0_notification_channel" "slack_webhook" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Slack Alerts spec: type: slack config: webhookURL: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" channel: "#alerts" frequency: 10m YAML } ``` -------------------------------- ### Email Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Configure an email notification channel to send alerts to specified recipients. Supports plaintext or formatted email content. ```terraform resource "dash0_notification_channel" "email" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Email Alerts spec: type: email_v2 config: recipients: - oncall@example.com - sre-team@example.com plaintext: false frequency: 10m YAML } ``` -------------------------------- ### Google Chat Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Configure Google Chat notifications with a webhook URL. Alerts are sent to the specified Google Chat space. ```terraform resource "dash0_notification_channel" "google_chat" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Google Chat Alerts spec: type: google_chat_webhook config: url: "https://chat.googleapis.com/v1/spaces/.../messages?key=..." frequency: 10m YAML } ``` -------------------------------- ### Microsoft Teams Notification Channel Source: https://github.com/dash0hq/terraform-provider-dash0/blob/main/docs/resources/notification_channel.md Configure Microsoft Teams notifications using a webhook URL. Alerts will be sent to the specified Teams channel. ```terraform resource "dash0_notification_channel" "teams" { notification_channel_yaml = <<-YAML kind: Dash0NotificationChannel metadata: name: Microsoft Teams Alerts spec: type: teams_webhook config: url: "https://example.webhook.office.com/webhookb2/..." frequency: 10m YAML } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.