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 host.name
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:
limits_config:
otlp_config:
resource_attributes:
attributes_config:
- action: index_label
attributes:
- host.name
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: https://opentelemetry.io/schemas/1.6.1
Resource attributes:
-> service.namespace: Str(demo-namespace)
-> service.name: Str(demo-service)
-> host.name: Str(example.com)
-> deployment.environment: Str(test)
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope
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)
Attributes:
-> log.file.name: 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 host.name
as an index label instead of structured metadata?
Thank you for your help!
Stephan