I am using Loki v3.4.2 and Grafana 11.5.1 to receive logs from an Open Telemetry Collector.
I am sending logs as structured metadata and want to add some extra fields from my log messages to show as labels in Grafana.
I have tried a number of different ways including reviewing the documentation here: Ingesting logs to Loki using OpenTelemetry Collector | Grafana Loki documentation as well as several other posts and am unable to resolve this.
My loki config has consisted of various versions of the following:
limits_config:
allow_structured_metadata: true
otlp_config:
resource_attributes:
attributes_config:
- action: index_label
attributes:
- service.group
log_attributes:
- action: structured_metadata
attributes:
- Alias
I’ve tried putting the attribute under resource_attributes, in the same group as service.group, as a separate group. I’ve also tried setting the default_resource_attributes_as_index_labels value as well.
distributor:
otlp_config:
default_resource_attributes_as_index_labels: ["Alias", "service.group"]
The log message I’m sending to Loki looks as follows:
2025-02-19T16:22:29 ScopeLogs SchemaURL:
2025-02-19T16:22:29 InstrumentationScope
2025-02-19T16:22:29 LogRecord #0
2025-02-19T16:22:29 ObservedTimestamp: 2025-02-19 06:22:26.3524881 +0000 UTC
2025-02-19T16:22:29 Timestamp: 2025-02-19 06:22:26.3524881 +0000 UTC
2025-02-19T16:22:29 SeverityText: Warning
2025-02-19T16:22:29 SeverityNumber: Warn(13)
2025-02-19T16:22:29 Body: Str(Test)
2025-02-19T16:22:29 Attributes:
2025-02-19T16:22:29 -> Alias: Str(MAIN)
2025-02-19T16:22:29 Trace ID:
2025-02-19T16:22:29 Span ID: c8dbaca31e6a3b9b
2025-02-19T16:22:29 Flags: 0
So it appears like the attribute is there. In Grafana, I can see the Alias attribute as a line in the log record, but it doesn’t appear in the label drop down. I’m not sure where to go from here, the documentation on this is very unclear.