Last updated:
dash0_log_event
Terraform action that sends an arbitrary log event to Dash0 via OTLP — the general-purpose counterpart to dash0_deployment_event, mirroring the dash0 logs send CLI command.
Sends a single log event to Dash0 via OTLP.
This is the general-purpose counterpart to the dash0_deployment_event action and mirrors the dash0 logs send CLI command: it emits an arbitrary log record with a free-form event name and attributes.
Requires the otlp_url provider attribute (or the DASH0_OTLP_URL environment variable).
Requires a static auth_-prefixed auth token: the Dash0 OTLP/HTTP ingress endpoint this action sends to does not accept OAuth access tokens, so credentials resolved from an OAuth-enabled dash0 CLI profile fail with an actionable error.
Actions require Terraform 1.14 or later.
Example Usage
terraform
# The general-purpose counterpart to dash0_deployment_event: an arbitrary log
# record with a free-form event name and attributes, mirroring `dash0 logs send`.
# Requires the provider's `otlp_url` attribute (or DASH0_OTLP_URL).
action "dash0_log_event" "migration_finished" {
config {
body = "Database migration ${var.migration_version} applied"
event_name = "acme.migration"
severity_number = 9
severity_text = "INFO"
# Attributes describing the entity the record is about.
resource_attributes = {
"service.name" = "checkout-api"
"deployment.environment.name" = "production"
}
# Attributes describing this individual event.
log_attributes = {
"migration.version" = var.migration_version
"migration.applied" = "true"
}
dataset = "production"
}
}
resource "null_resource" "database_migration" {
# ... migration configuration ...
lifecycle {
action_trigger {
events = [after_create, after_update]
actions = [action.dash0_log_event.migration_finished]
}
}
}
# Correlate the record with an existing trace by supplying both halves of the
# trace context. Setting only one of the two is a configuration error.
action "dash0_log_event" "correlated" {
config {
body = "Request processed"
trace_id = "0af7651916cd43dd8448eb211c80319c"
span_id = "b7ad6b7169203331"
dataset = "production"
}
}
# Treat a delivery failure as fatal. The default is false, so that a transient
# ingestion problem does not fail an apply.
action "dash0_log_event" "audit_record" {
config {
body = "Terraform applied infrastructure changes"
event_name = "acme.audit"
severity_number = 9
dataset = "production"
fail_on_error = true
}
}Schema
Required
body(String) The log record body, i.e. the human-readable message.dataset(String) The identifier of the Dash0 dataset the event is sent to. Provide the dataset's identifier, which is immutable, not the 'name'.
Optional
event_name(String) The event name, which identifies the kind of event this record represents (for exampledash0.deployment). See the event registry for the events Dash0 recognizes. Omit for a plain log record with no event name.fail_on_error(Boolean) Whether a delivery failure fails the Terraform run. Defaults tofalse: undelivered telemetry is reported as a warning so that a transient ingestion problem does not fail an apply, and so that an action wired tobefore_createcannot block the resource it annotates. Set totruewhen the event is load-bearing. Configuration mistakes (a missingotlp_url, an OAuth token, an emptybody, or malformedtrace_id/span_id) always fail regardless of this setting, since none of them survive a retry.log_attributes(Map of String) Attributes describing this individual event rather than the entity, attached to the log record itself.observed_time(String) The observed timestamp as an RFC3339 timestamp with optional nanoseconds. Defaults to the time the action is invoked.resource_attributes(Map of String) Attributes describing the entity the record is about, attached to the OTLP resource (for exampleservice.name,deployment.environment.name). Prefer OpenTelemetry semantic convention keys.severity_number(Number) The OpenTelemetry severity number (1–24). Dash0 derives the severity range from this value. It is independent ofseverity_text. Omit to send no severity number.severity_text(String) The severity text (for example "INFO", "WARN", "ERROR"). This is independent ofseverity_numberand can carry custom severity labels the way logging libraries do.span_id(String) The span ID to correlate this record with, as 16 hexadecimal characters. Must be set together withtrace_id.time(String) The log record timestamp as an RFC3339 timestamp with optional nanoseconds (for example "2024-03-15T10:30:00.123456789Z"). Defaults to the time the action is invoked.trace_id(String) The trace ID to correlate this record with, as 32 hexadecimal characters. Must be set together withspan_id.