Otel ottl
Skill ollygarden/opentelemetry-agent-skills/skills/otel-ottl
OpenTelemetry Transformation Language (OTTL) expert for writing and debugging telemetry transformations in the OpenTelemetry Collector. Use when authoring or reviewing `transform`, `filter`, `tail_sampling` processor configs or `routing` connector configs, debugging OTTL syntax or semantics, transforming traces, metrics, logs, or profiles, or converting data-processing requirements into OTTL statements.From its SKILL.md
npx -y skills add ollygarden/opentelemetry-agent-skills --skill otel-ottlAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
5.6 KB, as published. Nobody here has run it
OpenTelemetry Transformation Language (OTTL)
OTTL transforms or selects telemetry inside Collector components. This skill is pinned to collector-contrib v0.158.0. Function, path, default, and feature-gate availability varies by release; when the user's version differs, verify against the matching upstream tag.
Workflow
- Choose the component.
transformrewrites,filterdrops,tail_samplingdecides whether to retain traces, androutingsends telemetry to pipelines. A component controls its available contexts and functions. - Choose the lowest usable context. Lower contexts can read their parents (for example, a span
can read
resource.attributes), but parents cannot read children. Usedatapointfor point attributes instead of traversingmetric.data_points. - Verify every emitted function, then write the statement. Confirm each function's exact
identifier and signature in references/functions.md. If an identifier
is absent, treat it as unsupported instead of deriving or substituting a plausible name. An
editor such as
setordelete_keymutates data and may have awherecondition. Converters such asParseJSONandIsMatchreturn values; they do not mutate. - Set error behavior deliberately.
ignorelogs statement errors and continues;silentcontinues without logging;propagatereturns the error and can cause the component to drop the payload. In v0.158, transform and filter default toignore; routing also defaults toignorewhile its beta default-error feature gate is enabled. For routing,ignoresends an errored payload todefault_pipelines; configure that fallback or the payload is dropped. - Verify end to end. Validate the exact Collector version, then send known telemetry and inspect file-exporter output. Use the telemetrygen recipe.
set(span.attributes["env"], "prod") where resource.attributes["env"] == nil
Load only what the task needs
- Contexts — exact paths, hierarchy, enums, and request metadata.
- Functions — editor/converter signatures and release availability.
- Quick reference — component YAML, recipes, escaping, troubleshooting, and safe skeletons.
For a single path or function, read only the relevant section instead of loading the full catalogs.
Safety and correctness gates
- Guard optional or polymorphic input before conversion:
where x != nil,IsString(x), or the appropriate type check. - For JSON-object-only work, guard both the type and shape before calling
ParseJSON, for exampleIsString(log.body) and IsMatch(log.body.string, "(?s)^\\s*\\{.*\\}\\s*$"). The RE2(?s)flag admits pretty-printed objects containing newlines. CheckingIsMapafter parsing does not prevent arrays or scalar JSON from being parsed. - On a version-pinned request, confirm every chosen path and function against that release tag;
do not assume a function listed for this skill's v0.158 anchor exists in an older release.
For v0.156 JSON-object parsing,
ParseJSON,IsString, andIsMatchare available without the v0.157 alpha lambda feature gate. - Request metadata is read-only and may contain credentials. Copy only explicitly allowlisted,
non-sensitive keys. OTLP metadata routing requires
include_metadata: trueon the receiver. HTTP/client header spelling may retain its form (otelcol.client.metadata["X-Tenant"][0]); gRPC metadata keys are lowercase (otelcol.grpc.metadata["x-tenant"][0]). - The routing
requestcontext is deprecated as of v0.156; useotelcol.client.metadataorotelcol.grpc.metadata. - Log-record-specific rewrites of shared resource or scope data require
flatten_data: trueand the alphatransform.flatten.logsgate. This copies and regroups data; do not enable it accidentally. - Hashing an identifier does not necessarily anonymize it. Apply the organization's data-handling policy before retaining deterministic hashes of personal data.
Frequent syntax traps
- In Collector YAML, write an OTTL replacement backreference
${1}as$${1}. A replacement such as$1REDACTEDis literal and silently fails to substitute the capture. - Go RE2 rejects large counted repetitions such as
(.{1024}).*; useSubstringwith a nil/type guard andLen, ortruncate_allfor a map. - Current span-event paths use
spanevent.*, notspan_event.*. Cache paths are context-qualified, such asspan.cache["parsed"]. - Use
Decode(value, "base64");Base64Decodeis deprecated. - Regex escapes inside OTTL strings are doubled (
\\d,\\s,\\.).
Upstream sources
What ships with it: 4 files
44.5 KB alongside SKILL.md
evals/
- evals.json2.5 KB
references/
- contexts.md10.9 KB
- functions.md19.3 KB
- quick-reference.md11.7 KB
Gives 0 of the 12 instructions most monitoring observability skills give
Counted across 530 of the 532 authors here whose files we hold, read 2026-09-06
- Use structured JSON loggingin 40 of 530, across 36 files
- Link every alert to a runbookin 29 of 530, across 27 files
- Attach correlation IDs to every log linein 19 of 530, across 16 files
- Alert on symptoms rather than causesin 19 of 530, across 17 files
- Use OpenTelemetry for distributed tracingin 15 of 530, across 14 files
- Alert on symptoms users feelin 15 of 530, across 13 files
- Implement health check endpointsin 14 of 530, across 10 files
- Inspect existing dashboards firstin 12 of 530, across 4 files
- Build the minimum useful boardin 12 of 530, across 4 files
- Start from operator questionsin 12 of 530, across 4 files
- Propagate trace context across boundariesin 11 of 530, across 10 files
- Include trace id in all log entriesin 10 of 530, across 9 files
Said here and by no other author read
- Choose the component
- Choose the lowest usable context
- Verify every emitted function
- Set error behavior deliberately
- Verify end to end
- Guard optional input before conversion
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.