Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for indexing log_attributes in OTLPConfig #15128 #15293

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

samuelarogbonlo
Copy link

Summary

This PR adds support for indexing log_attributes in the OTLPConfig for Grafana Loki. Currently, Loki supports indexing resource_attributes but lacks similar functionality for log_attributes. This enhancement allows users to specify log_attributes to be indexed as labels directly from OTLP logs, improving flexibility and functionality.

This PR resolves Loki Issue #15128.

Changes Made

  1. Extended OTLPConfig to process log_attributes with the action index_label.
  2. Updated the logic in otlp_config.go to support log_attributes configuration:
    • Added support for indexing attributes.
    • Ensured compatibility with existing resource_attributes.
  3. Added new test cases in otlp_config_test.go:
    • Validated that log_attributes with action: index_label are processed correctly.
    • Ensured proper handling of regex-based configurations.
    • Added checks for misconfigurations (e.g., both attributes and regex being set).
  4. Ensured existing test cases for resource_attributes remain unaffected.

Testing Performed

Automated Tests

  • Added the following test cases in otlp_config_test.go:

    • log_attributes indexing: Validates indexing of log_attributes with specified attributes.
    • log_attributes with regex: Ensures regex-based matching for log_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 both attributes and regex 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:

ok  	github.com/grafana/loki/v3/pkg/loghttp/push	0.790s

Checklist

  • [✅] Code changes are committed and pushed to the feature branch.
  • [✅] Added and updated test cases in otlp_config_test.go.
  • [✅] All tests have passed locally.
  • [✅] PR description includes:
    • [✅] Summary of the changes.
    • [✅] List of changes made.
    • [✅] Details of testing performed.
    • [✅] Example configuration.
    • [✅] Link to the related issue.

@samuelarogbonlo samuelarogbonlo requested a review from a team as a code owner December 5, 2024 21:45
@CLAassistant
Copy link

CLAassistant commented Dec 5, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OTLP] index_label from log_attributes
2 participants