Supported pipeline types: logs, traces
The transform processor modifies telemetry based on configuration using the Telemetry Query Language.
It takes a list of queries which are performed in the order specified in the config.
Queries are composed of the following parts
- Path expressions: Fields within the incoming data can be referenced using expressions composed of the names as defined
in the OTLP protobuf definition. e.g., status.code,attributes["http.method"]. If the path expression begins withresource.orinstrumentation_library., it will reference those values.
- The name instrumentation_librarywithin OpenTelemetry is currently under discussion and may be changed in the future.
 
- Literals: Strings, ints, and floats can be referenced as literal values
- Function invocations: Functions can be invoked with arguments matching the function's expected arguments
- Where clause: Telemetry to modify can be filtered by appending where a <op> b, withaandbbeing any of the above.
Supported functions:
- 
set(target, value)-targetis a path expression to a telemetry field to setvalueinto.valueis any value type.
e.g.,set(attributes["http.path"], "/foo"),set(name, attributes["http.route"]). Ifvalueresolves tonil, e.g.
it references an unset map value, there will be no action.
 
- 
keep_keys(target, string...)-targetis a path expression to a map type field. The map will be mutated to only contain
the fields specified by the list of strings. e.g.,keep_keys(attributes, "http.method"),keep_keys(attributes, "http.method", "http.route")
 
Supported where operations:
- ==- matches telemetry where the values are equal to each other
- !=- matches telemetry where the values are not equal to each other
Example configuration:
receivers:
  otlp:
    protocols:
      grpc:
exporters:
  nop
processors:
  transform:
    logs:
      queries:
        - set(severity_text, "FAIL") where body == "request failed"
        - keep_keys(resource.attributes, "service.name", "service.namespace", "cloud.region")
        - set(body, attributes["http.route"])
    traces:
      queries:
        - set(status.code, 1) where attributes["http.path"] == "/health"
        - keep_keys(resource.attributes, "service.name", "service.namespace", "cloud.region")
        - set(name, attributes["http.route"])
service:
  pipelines:
    logs:
      receivers: [otlp]
      processors: [transform]
      exporters: [nop]
    traces:
      receivers: [otlp]
      processors: [transform]
      exporters: [nop]
This processor will perform the operations in order for
All logs
- Set severity text to FAIL if the body contains a string text "request failed"
- Keep only service.name,service.namespace,cloud.regionresource attributes
- Set bodyto thehttp.routeattribute if it is set
All spans
- Set status code to OK for all spans with a path /health
- Keep only service.name,service.namespace,cloud.regionresource attributes
- Set nameto thehttp.routeattribute if it is set