Loading...
Loading...
OpenTelemetry Transformation Language (OTTL) expert. Use when writing or debugging OTTL expressions for any OpenTelemetry Collector component that supports OTTL (processors, connectors, receivers, exporters). Triggers on tasks involving telemetry transformation, filtering, attribute manipulation, data redaction, sampling policies, routing, or Collector configuration. Covers syntax, contexts, functions, error handling, and performance.
npx skill4agent add dash0hq/agent-skills otel-ottl| Component | Use case |
|---|---|
| transform | Modify, enrich, or redact telemetry (set attributes, rename fields, truncate values) |
| filter | Drop telemetry entirely (discard metrics by name, drop spans by status, remove noisy logs) |
| attributes | Insert, update, delete, or hash resource and record attributes |
| span | Rename spans and set span status based on attribute values |
| tailsampling | Sample traces based on OTTL conditions (e.g., keep error traces, drop health checks) |
| cumulativetodelta | Convert cumulative metrics to delta temporality with OTTL-based metric selection |
| logdedup | Deduplicate log records using OTTL conditions |
| lookup | Enrich telemetry by looking up values from external tables using OTTL expressions |
| Component | Use case |
|---|---|
| routing | Route telemetry to different pipelines based on OTTL conditions |
| count | Count spans, metrics, or logs matching OTTL conditions and emit as metrics |
| sum | Sum numeric values from telemetry matching OTTL conditions and emit as metrics |
| signaltometrics | Generate metrics from spans or logs using OTTL expressions for attribute extraction |
| Component | Use case |
|---|---|
| hostmetrics | Filter host metrics at collection time using OTTL conditions |
span.name
span.attributes["http.method"]
resource.attributes["service.name"]resourcescopespanspaneventmetricdatapointlogspan.status.code == STATUS_CODE_ERROR
span.kind == SPAN_KIND_SERVER| Category | Operators |
|---|---|
| Assignment | |
| Comparison | |
| Logical | |
ToUpperCase(span.attributes["http.request.method"])
Substring(log.body.string, 0, 1024)
Concat(["prefix", span.attributes["request.id"]], "-")
IsMatch(metric.name, "^k8s\\..*$")set(span.attributes["region"], "us-east-1")
delete_key(resource.attributes, "internal.key")
limit(log.attributes, 10, [])wherespan.attributes["db.statement"] = "REDACTED" where resource.attributes["service.name"] == "accounting"nilnullresource.attributes["service.name"] != nilset(resource.attributes["k8s.cluster.name"], "prod-aws-us-west-2")set(span.attributes["http.request.header.authorization"], "REDACTED") where span.attributes["http.request.header.authorization"] != nilIsMatch(metric.name, "^k8s\\.replicaset\\..*$")time_unix_nano < UnixNano(Now()) - 21600000000000processors:
transform:
log_statements:
- context: log
statements:
- set(log.observed_time, Now()) where log.observed_time_unix_nano == 0
- set(log.time, log.observed_time) where log.time_unix_nano == 0processors:
filter:
metrics:
datapoint:
- 'IsMatch(ConvertCase(String(metric.name), "lower"), "^k8s\\.replicaset\\.")'
service:
pipelines:
metrics:
receivers: [otlp]
processors: [filter, batch]
exporters: [debug]processors:
transform:
trace_statements:
- context: span
statements:
- set(span.status.code, STATUS_CODE_ERROR) where span.attributes["http.response.status_code"] >= 500
- set(span.attributes["env"], "production") where resource.attributes["deployment.environment"] == "prod"
service:
pipelines:
traces:
receivers: [otlp]
processors: [transform, batch]
exporters: [debug]nilresource.attributes["service.namespace"] != nil
and
IsMatch(ConvertCase(String(resource.attributes["service.namespace"]), "lower"), "^platform.*$")error_modepropagate| Mode | Behavior | When to use |
|---|---|---|
| Stops processing current item | Development and strict environments where you want to catch every error |
| Logs error, continues processing | Production — set this unless you have a specific reason not to |
| Ignores errors without logging | High-volume pipelines with known-safe transforms where error logs are noise |
processors:
transform:
error_mode: ignore
trace_statements:
- context: span
statements:
- set(span.attributes["parsed"], ParseJSON(span.attributes["json_body"]))where| Function | Signature | Description |
|---|---|---|
| | Appends single or multiple values to a target field, converting scalars to arrays if needed |
| | Removes a key from a map |
| | Removes all keys matching a regex pattern |
| | Flattens nested maps to the root level |
| | Removes all keys NOT in the supplied list |
| | Keeps only keys matching a regex pattern |
| | Reduces map size to not exceed limit, preserving priority keys |
| | Merges source into target (strategy: |
| | Replaces matching string values using glob patterns |
| | Replaces segments matching regex (mode: |
| | Replaces entire string if it matches a glob pattern |
| | Replaces string sections matching a regex |
| | Sets a telemetry field to a value |
| | Truncates all string values in a map to a max length |
| Function | Signature | Description |
|---|---|---|
| | Returns true if value is boolean |
| | Returns true if value is float64 |
| | Returns true if value is int64 |
| | Returns true if value is a map |
| | Returns true if value is a list |
| | Returns true if target matches regex pattern |
| | Returns true if span has no parent |
| | Returns true if value is a string |
| Function | Signature | Description |
|---|---|---|
| | Converts value to boolean |
| | Converts value to float64 |
| | Converts value to int64 |
| | Converts value to string |
| Function | Signature | Description |
|---|---|---|
| | Concatenates values with a delimiter |
| | Converts to |
| | Returns true if value starts with prefix |
| | Returns true if value ends with suffix |
| | Returns first index of value in target, or -1 |
| | Splits string into array by delimiter |
| | Extracts substring from start position |
| | Converts to CamelCase |
| | Converts to lowercase |
| | Converts to snake_case |
| | Converts to UPPERCASE |
| | Removes leading/trailing characters |
| | Removes leading prefix |
| | Removes trailing suffix |
| Function | Signature | Description |
|---|---|---|
| | Returns FNV hash as int64 |
| | Returns MD5 hash as hex string |
| | Returns 32-bit Murmur3 hash as hex string |
| | Returns 128-bit Murmur3 hash as hex string |
| | Returns SHA1 hash as hex string |
| | Returns SHA256 hash as hex string |
| | Returns SHA512 hash as hex string |
| Function | Signature | Description |
|---|---|---|
| | Decodes string (base64, base64-raw, base64-url, IANA encodings) |
| | Returns hexadecimal representation |
| Function | Signature | Description |
|---|---|---|
| | Extracts named regex capture groups into a map |
| | Parses unstructured data using grok patterns |
| | Parses CSV string to map |
| | Parses string as integer in given base (2-36) |
| | Parses JSON string to map or slice |
| | Parses key-value string to map |
| | Maps log level value to severity string |
| | Parses XML string to map (ignores attributes) |
| | Parses XML string to map (preserves structure) |
| Function | Signature | Description |
|---|---|---|
| | Returns day component from time |
| | Parses duration string (e.g. |
| | Formats time to string using Go layout |
| | Returns hour component from time |
| | Returns duration as floating-point hours |
| | Returns minute component from time |
| | Returns duration as floating-point minutes |
| | Returns month component from time |
| | Returns nanosecond component from time |
| | Returns duration as nanosecond count |
| | Returns current time |
| | Returns second component from time |
| | Returns duration as floating-point seconds |
| | Parses string to time |
| | Truncates time to multiple of duration |
| | Creates time from Unix epoch |
| | Returns time as microseconds since epoch |
| | Returns time as milliseconds since epoch |
| | Returns time as nanoseconds since epoch |
| | Returns time as seconds since epoch |
| | Returns day of week from time |
| | Returns year component from time |
| Function | Signature | Description |
|---|---|---|
| | Returns true if item exists in slice |
| | Formats string using |
| | Returns all keys from a map |
| | Returns length of string, slice, or map |
| | Converts slice of objects to map |
| | Sorts array ( |
| | Converts map to key-value string |
| | Returns all values from a map |
| Function | Signature | Description |
|---|---|---|
| | Creates ProfileID from 16 bytes or 32 hex chars |
| | Creates SpanID from 8 bytes or 16 hex chars |
| | Creates TraceID from 16 bytes or 32 hex chars |
| | Generates a new UUID |
| | Generates a new UUIDv7 |
| Function | Signature | Description |
|---|---|---|
| | Converts XML attributes to child elements |
| | Wraps XML text content in elements |
| | Returns XML elements matching XPath |
| | Inserts XML at XPath locations |
| | Removes XML elements matching XPath |
| Function | Signature | Description |
|---|---|---|
| | Generates network flow hash |
| | Returns true if value passes Luhn check |
| | Returns natural logarithm as float64 |
| | Parses URL into components (scheme, host, path, etc.) |
| | Parses user-agent string into map (name, version, OS) |