Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions observability/otel/otel-collector/otel-collector-processors.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,94 @@ config: |
<2> Defines a value provided in the `metrics` field as a `strict` exact match or `regexp` regular expression.
<3> Lists the metric names, which are exact matches or matches for regular expressions, of the metrics to be converted to delta metrics. If a metric matches both the `include` and `exclude` filters, the `exclude` filter takes precedence.
<4> Optional: Configures which metrics to exclude. When omitted, no metrics are excluded from conversion to delta metrics.

[id="transform-processor_{context}"]
== Transform Processor

With this processor telemetry data can be modified based on some rules and using OpenTelemetry Transformation Language.

For each signal type, the processor processes a series of conditions and statements associated with a specific Context type, executing them in sequence on incoming telemetry as specified in the configuration. Each condition and statement can access and modify the telemetry using various functions, allowing conditions to dictate whether a function should be executed.

Multiple context statements can be configure for the different signals, traces, metrics, and logs. The value of context specifies which OTTL Context to use when interpreting the associated statements

Usually the configuration has the following structure:

[source,yaml]
----
config: |
processors:
transform:
error_mode: ignore # <1>
<trace|metric|log>_statements: # <2>
- context: string # <3>
conditions: # <4>
- string
- string
statements: # <5>
- string
- string
- string
- context: string
statements:
- string
- string
- string
----
<1> The transform processor also allows configuring an optional field, `error_mode`, which will determine how the processor reacts to errors that occur while processing a statement.

<2> This indicate the signal that will be transformed.

<3> Valid values for context are depending on the signal, the following table indicate possible values:

<4> Conditions that need to match in order to do the transformation (if any)

Possible values for error_mode:
|===
|Value |Description
|`ignore`
| ignore errors returned by statements and continue to the next oneDefault mode is propagated.
|`silent`
| ignore the errors, but the difference is that this doesn't log the error.
|`propagate`
| return error and drop the payload.
|===
Possible values for context, depending on the signal:
|===
|Signal Statement |Valid Contexts
|`trace_statements`
| resource, scope, span, and spanevent.
|`metric_statements`
| resource, scope, metric, and datapoint.
|`log_statements`
| resource, scope, and log.
|===

For example, statements associated to a resource context will be able to transform the resource's `attributes` and `dropped_attributes_count`.

The following example transforms a trace signal, keeping some keys on the resources, and replace some attributes, in this case the password fields are enmascarated. It also does some transformations at the span level (span context).

[source,yaml]
----
config: |
transform:
error_mode: ignore
trace_statements:
- context: resource
statements:
- keep_keys(attributes, ["service.name", "service.namespace", "cloud.region", "process.command_line"])
- replace_pattern(attributes["process.command_line"], "password\\=[^\\s]*(\\s?)", "password=***")
- limit(attributes, 100, [])
- truncate_all(attributes, 4096)
- context: span
statements:
- set(status.code, 1) where attributes["http.path"] == "/health"
- set(name, attributes["http.route"])
- replace_match(attributes["http.target"], "/user/*/list/*", "/user/{userId}/list/{listId}")
- limit(attributes, 100, [])
- truncate_all(attributes, 4096)
----

All statements are defined using, for more information link:https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl[OpenTelemetry Transformation Language]


[OpenTelemetry Transformation Language]()