I send logs using Alloy 1.8.2 to Loki (tested with 3.4.2 and 3.5.0) with OTLP endpoint. This works fine.
The configuration of the indexed labels in Loki is changed to allow only a few labels to be indexed. But this does not work. The service.name in Loki becomes unknown_service
and all other fields are structured_metadata and not indexed fields. I’ve been searching and testing a whiole day and tried several configurations I found but I cannot gwet it working.
What I am doing wrong?
I sent some sample requests using curl to Loki. It seems that attributes in resource
section become indexed labels and attributes in logRecords
section not. Can I change this with Alloy?
Loki config
limits_config:
allow_structured_metadata: true
otlp_config:
resource_attributes:
# ignore_defaults: true
attributes_config:
- action: index_label
attributes:
- customer
- hostname
- host.name
- job
- service.name
- stage
distributor:
otlp_config:
default_resource_attributes_as_index_labels: []
Sample log from Alloy live debug
LogRecord #0
ObservedTimestamp: 2025-05-08 08:40:12.009693043 +0000 UTC
Timestamp: 2025-05-08 08:40:11.548241 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(Removed slice User Slice of UID 0.)
Attributes:
-> service_name: Str(integrations/journald)
-> host.name: Str(test)
-> job: Str(integrations/journald)
-> systemd_unit: Str(init.scope)
-> service.name: Str(integrations/journald)
-> stage: Str(test)
-> customer: Str(demo)
Trace ID:
Sample log in Grafana