-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[lokiexporter] Add Resource Attributes as Loki Label #3418
[lokiexporter] Add Resource Attributes as Loki Label #3418
Conversation
Fixes typo and used semantic conventions Co-authored-by: gregoryfranklin <45693481+gregoryfranklin@users.noreply.github.com>
Excellent work, @eroteme! From a quick pass everything looks good; however, I will allocate more time tomorrow to dive in and perform a deeper review. What are your thoughts on how you would like to handle duplicate labels? |
For duplicate labels, it might be worth considering the prometheus exporter as prior-art? Although, given you are explicitly listing which labels come from the Resource and which labels come from the LogRecord in the config, I don't think this is a big deal since you would have to explicitly configure a duplicate label situation. |
Thank you so much for the prompt response! I personally like the idea of following the Prometheus exporter and overwriting the log attributes with the resource attributes. Let's try to do that in this PR. |
The prometheus model.labelset Merge function used just needed reversing in this case but I've added a comment to show that this is happening in the Merge
This should mean that the logrecord attributes are overwritten by the resource attributes |
I've tried to remove as much duplicated code by passing the attributes into the get attribute functions. I also noticed that the lokiExporter was storing the attribute labels when they where accessible from the config anyway. Let me know if this is ok. |
@eroteme - This looks good. Could you rebase from main? |
@bogdandrutu @tigrannajaryan - Can you allow the pipeline to run? Since @eroteme is a first time contributor to this repository, GitHub workflows require a Maintainer to approve running the workflow. |
@gramidt pipeline ran, but not sure what to do, can you approve if ready to merge? |
Thank you for your contribution, @eroteme! |
Description:
Logrecord attributes usually only give information at the log level (such a severity and request url, etc).
Resource attributes usually add the context of what resource sent the log (such as container_name or cluster_name etc).
Currently the loki exporter is able to add logrecord attributes to loki labels. This PR adds Resource attributes also, which helps with filtering of loki data on both log attributes and resource attributes.
Link to tracking Issue:
#3405
Testing:
Added a few tests and a basic run of the exporter. I still have some questions about what happens if we have attributes with the same key on both log records and resources and which we would choose and how we deduplicate
Documentation:
Updated README.md, added code comments for doc creation