Add support for indexing log_attributes in OTLPConfig #15128 #15293
+99
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for indexing
log_attributes
in the OTLPConfig for Grafana Loki. Currently, Loki supports indexingresource_attributes
but lacks similar functionality forlog_attributes
. This enhancement allows users to specifylog_attributes
to be indexed as labels directly from OTLP logs, improving flexibility and functionality.This PR resolves Loki Issue #15128.
Changes Made
OTLPConfig
to processlog_attributes
with the actionindex_label
.otlp_config.go
to supportlog_attributes
configuration:resource_attributes
.otlp_config_test.go
:log_attributes
withaction: index_label
are processed correctly.attributes
andregex
being set).resource_attributes
remain unaffected.Testing Performed
Automated Tests
Added the following test cases in
otlp_config_test.go
:log_attributes indexing
: Validates indexing oflog_attributes
with specified attributes.log_attributes with regex
: Ensures regex-based matching forlog_attributes
works.unsupported action should error
: Verifies that unsupported actions produce errors.attributes and regex both not set should error
: Tests error handling for invalid configurations.attributes and regex both being set should error
: Confirms that specifying bothattributes
andregex
produces an error.Ran all tests in the
pkg/loghttp/push
package:go test ./pkg/loghttp/push/...
Test Results
All tests in
pkg/loghttp/push
passed successfully:Checklist
otlp_config_test.go
.