otelcol.connector.spanlogs accepts traces telemetry data from other otelcol
components and outputs logs telemetry data for each span, root, or process.
This allows you to automatically build a mechanism for trace discovery.
Note
otelcol.connector.spanlogs is a custom component unrelated to any components from the OpenTelemetry Collector.
It is based on the automatic_logging component in the traces subsystem of Grafana Agent Static.
You can specify multiple otelcol.connector.spanlogs components by giving them different labels.
The overrides block configures overrides for keys that will be logged in the body of the log line.
The following attributes are supported:
Name
Type
Description
Default
Required
logs_instance_tag
string
Indicates if the log line is for a span, root, or process.
traces
no
service_key
string
Log key for the service name of the resource.
svc
no
span_name_key
string
Log key for the name of the span.
span
no
status_key
string
Log key for the status of the span.
status
no
duration_key
string
Log key for the duration of the span.
dur
no
trace_id_key
string
Log key for the trace ID of the span.
tid
no
output block
The output block configures a set of components to forward resulting telemetry data to.
The following arguments are supported:
Name
Type
Description
Default
Required
logs
list(otelcol.Consumer)
List of consumers to send logs to.
[]
no
You must specify the output block, but all its arguments are optional.
By default, telemetry data is dropped.
Configure the logs argument accordingly to send telemetry data to other components, .
Exported fields
The following fields are exported and can be referenced by other components:
Name
Type
Description
input
otelcol.Consumer
A value that other components can use to send telemetry data to.
input accepts otelcol.Consumer data for any telemetry signal (metrics, logs, or traces).
Component health
otelcol.connector.spanlogs is only reported as unhealthy if given an invalid configuration.
Debug information
otelcol.connector.spanlogs does not expose any component-specific debug information.
Example
The following configuration sends logs derived from spans to Loki.
Additionally, otelcol.processor.attributes is configured with a “hint” so that
otelcol.exporter.loki promotes the span’s “attribute1” attribute to a Loki label.
Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.