Add additional index labels in Loki 3.0

Hi everyone,

I use Loki 3.0 and ingest logs in OTLP format with the OpenTelemetry Collector and the otlphttp exporter.
Everything works as expected, but I cannot add the resource attribute as an additional index label. The attribute is instead added as structured metadata.

I followed the instructions here: Ingesting logs to Loki using OpenTelemetry Collector | Grafana Loki documentation

Other resource attributes from the list of default labels like deployment.environment are converted to index labels as expected.

This is the section from Loki’s configuration file:

        - action: index_label

In the OpenTelemetry Collector debug log, the log record that is sent to Loki looks like this:

2024-05-07T15:48:48.551+0200        info        ResourceLog #0
Resource SchemaURL:
Resource attributes:
     -> service.namespace: Str(demo-namespace)
     -> Str(demo-service)
     -> Str(
     -> deployment.environment: Str(test)
ScopeLogs #0
ScopeLogs SchemaURL:
LogRecord #0
ObservedTimestamp: 2024-05-07 13:48:47.895773234 +0000 UTC
Timestamp: 2024-05-07 13:48:47.701 +0000 UTC
SeverityText: DEBUG
SeverityNumber: Debug(5)
Body: Str(log content)
     -> Str(log.ndjson)
     -> log.file.path: Str(/path/to/logs/log.ndjson)
Trace ID: dac9c66b486632ce141cbe9a98712c41
Span ID: 4b9cf39a00f42ce9
Flags: 1

What could I do to store as an index label instead of structured metadata?

Thank you for your help!

I’ve not tried using otlp collector with Loki, but according to documentation there is a list of fixed attributes that get mapped to labels. See Ingesting logs to Loki using OpenTelemetry Collector | Grafana Loki documentation

Thanks for you response!
I followed the documentation, there is a section about how to extend the built-in list of attributes:

But these settings do not seem to have any effect in my installation. I also tried to disable the default attributes as described here, but it also did not work:

I’m having the same problem. As a workaround I just changed the default list of resource attributes that gets mapped via the distributor config, but that’s not ideal. Example:

        - foo
        - bar