Skip to content

Commit f7e160f

Browse files
committed
OBSDOCS-1151: Add documentation for transform processor
Signed-off-by: Ruben Vargas [email protected]
1 parent 7147bba commit f7e160f

File tree

1 file changed

+106
-1
lines changed

1 file changed

+106
-1
lines changed

observability/otel/otel-collector/otel-collector-processors.adoc

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ config: |
394394
<2> The default exporter when the attribute value is not present in the table in the next section.
395395
<3> The table that defines which values are to be routed to which exporters.
396396

397-
You can optionally create an `attribute_source` configuration, which defines where to look for the attribute in `from_attribute`. The allowed value is `context` to search the context, which includes the HTTP headers, or `resource` to search the resource attributes.
397+
Optionally, you can create an `attribute_source` configuration, which defines where to look for the attribute that you specify in the `from_attribute` field. The supported values are `context` for searching the context including the HTTP headers, and `resource` for searching the resource attributes.
398398

399399
[id="cumulativetodelta-processor_{context}"]
400400
== Cumulative-to-Delta Processor
@@ -453,3 +453,108 @@ processors:
453453
----
454454
<1> Specifies attribute keys to group by.
455455
<2> If a processed span, log record, or metric datapoint contains at least one of the specified attribute keys, it is reassigned to a Resource that shares the same attribute values; and if no such Resource exists, a new one is created. If none of the specified attribute keys is present in the processed span, log record, or metric datapoint, then it remains associated with its current Resource. Multiple instances of the same Resource are consolidated.
456+
457+
[id="transform-processor_{context}"]
458+
== Transform Processor
459+
460+
The Transform Processor enables modification of telemetry data according to specified rules and in the link:https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl[OpenTelemetry Transformation Language (OTTL)].
461+
For each signal type, the processor processes a series of conditions and statements associated with a specific OTTL Context type and then executes them in sequence on incoming telemetry data as specified in the configuration.
462+
Each condition and statement can access and modify telemetry data by using various functions, allowing conditions to dictate if a function is to be executed.
463+
464+
All statements are written in the OTTL.
465+
You can configure multiple context statements for different signals, traces, metrics, and logs.
466+
The value of the `context` type specifies which OTTL Context the processor must use when interpreting the associated statements.
467+
468+
:FeatureName: The Transform Processor
469+
include::snippets/technology-preview.adoc[]
470+
471+
.Configuration summary
472+
[source,yaml]
473+
----
474+
# ...
475+
config: |
476+
processors:
477+
transform:
478+
error_mode: ignore # <1>
479+
<trace|metric|log>_statements: # <2>
480+
- context: <string> # <3>
481+
conditions: # <4>
482+
- <string>
483+
- <string>
484+
statements: # <5>
485+
- <string>
486+
- <string>
487+
- <string>
488+
- context: <string>
489+
statements:
490+
- <string>
491+
- <string>
492+
- <string>
493+
# ...
494+
----
495+
<1> Optional: See the following table "Values for the optional `error_mode` field".
496+
<2> Indicates a signal to be transformed.
497+
<3> See the following table "Values for the `context` field".
498+
<4> Optional: Conditions for performing a transformation.
499+
500+
.Configuration example
501+
[source,yaml]
502+
----
503+
# ...
504+
config: |
505+
transform:
506+
error_mode: ignore
507+
trace_statements: # <1>
508+
- context: resource
509+
statements:
510+
- keep_keys(attributes, ["service.name", "service.namespace", "cloud.region", "process.command_line"]) # <2>
511+
- replace_pattern(attributes["process.command_line"], "password\\=[^\\s]*(\\s?)", "password=***") # <3>
512+
- limit(attributes, 100, [])
513+
- truncate_all(attributes, 4096)
514+
- context: span # <4>
515+
statements:
516+
- set(status.code, 1) where attributes["http.path"] == "/health"
517+
- set(name, attributes["http.route"])
518+
- replace_match(attributes["http.target"], "/user/*/list/*", "/user/{userId}/list/{listId}")
519+
- limit(attributes, 100, [])
520+
- truncate_all(attributes, 4096)
521+
# ...
522+
----
523+
<1> Transforms a trace signal.
524+
<2> Keeps keys on the resources.
525+
<3> Replaces attributes and replaces string characters in password fields with asterisks.
526+
<4> Performs transformations at the span level.
527+
528+
.Values for the `context` field
529+
[options="header"]
530+
[cols="a,a"]
531+
|===
532+
|Signal Statement |Valid Contexts
533+
534+
|`trace_statements`
535+
|`resource`, `scope`, `span`, `spanevent`
536+
537+
|`metric_statements`
538+
|`resource`, `scope`, `metric`, `datapoint`
539+
540+
|`log_statements`
541+
|`resource`, `scope`, `log`
542+
543+
|===
544+
545+
.Values for the optional `error_mode` field
546+
[options="header"]
547+
[cols="a,a"]
548+
|===
549+
|Value |Description
550+
551+
|`ignore`
552+
|Ignores and logs errors returned by statements and then continues to the next statement.
553+
554+
|`silent`
555+
|Ignores and doesn't log errors returned by statements and then continues to the next statement.
556+
557+
|`propagate`
558+
|Returns errors up the pipeline and drops the payload. Implicit default.
559+
560+
|===

0 commit comments

Comments
 (0)