OpenTelemetry envelope

The OpenTelemetry envelope processor transforms your data to be compatible with the OpenTelemetry log schema. If your data wasn't generated by the OpenTelemetry input plugin, you can use this processor before sending that data to a destination that expects an OpenTelemetry-compatible schema.

OpenTelemetry envelope transformation

Only YAML configuration files support processors.

Configuration parameters

The OpenTelemetry envelope processor doesn't use configuration parameters.

Examples

The following example uses the dummy input plugin to generate one sample message per second, then transforms those messages by using the opentelemetry_envelope processor. The resulting transformed data is sent to stdout and the opentelemetry output plugin.

service:
  flush: 1
  log_level: info

pipeline:
  inputs:
    - name: dummy
      dummy: '{"message": "Hello World"}'

      processors:
        logs:
          - name: opentelemetry_envelope

  outputs:
    - name : stdout
      match: '*'

    - name: opentelemetry
      match: '*'
      host: 127.0.0.1
      port: 4318

The standard output of Fluent Bit prints the raw representation of the schema. However, the OpenTelemetry collector receives the data in an OpenTelemetry-compatible format.

If you inspect the out.json output file, you will see OpenTelemetry-compatible data, similar to the following:

{
  "resourceLogs": [
    {
      "resource": {},
      "scopeLogs": [
        {
          "scope": {},
          "logRecords": [
            {
              "timeUnixNano": "1722904188085758000",
              "body": {
                "stringValue": "dummy"
              },
              "traceId": "",
              "spanId": ""
            }
          ]
        }
      ]
    }
  ]
}

If you're interested in additional transformations, you can also use the content modifier processor to modify the content of your logs. The following example shows how to add resource and scope attributes to logs:

service:
  flush: 1
  log_level: info

pipeline:
  inputs:
    - name: dummy
      dummy: '{"message": "Hello World"}'

      processors:
        logs:
          - name: opentelemetry_envelope

          - name: content_modifier
            context: otel_resource_attributes
            action: upsert
            key: service.name
            value: my-service

  outputs:
    - name : stdout
      match: '*'

    - name: opentelemetry
      match: '*'
      host: 127.0.0.1
      port: 4318

The collector JSON output will resemble the following:

{
  "resourceLogs": [
    {
      "resource": {
        "attributes": [
          {
            "key": "service.name",
            "value": {
              "stringValue": "my-service"
            }
          }
        ]
      },
      "scopeLogs": [
        {
          "scope": {},
          "logRecords": [
            {
              "timeUnixNano": "1722904465173450000",
              "body": {
                "stringValue": "Hello World"
              },
              "traceId": "",
              "spanId": ""
            }
          ]
        }
      ]
    }
  ]
}

For more details about further processing, read the content modifier processor documentation.

Last updated

Was this helpful?