Enriching fluent-bit logs with opentelemetry resource attributes while sending logs to loki
08:08 05 Apr 2025

Context: I am collecting Kubernetes logs from the cluster using fluent-bit v3.2. And I am sending the logs to Loki.

I want to migrate to be compatible with OpenTelemetry. I know Fluent-bit supports schema conversion using the OpenTelemetry envelope and provides an OpenTelemetry output plugin. I am using both. I can successfully send data to Loki, but without labels.

I want to set the otel_resource_attributes while sending logs to Loki, so that these labels(service.name, container.name) become labels in Loki.

I am using kubernetes filter to enrich log files with Kubernetes metadata.

   [FILTER]
    Name             kubernetes
    Match            kube.*
    ...

Problem: I can't find a way to enrich the otel_resource_attributes by extracting data from kubernetes metadata.

What I tried?

Try Result
processor: content_modifer: insert key, value pair Supports static values for labels. But I can't find a way to extract data from kubernetes metadata
output: opentelemetry: add_labels Doesnot support logs
open-telemetry fluent grafana-loki open-telemetry-collector