-
Notifications
You must be signed in to change notification settings - Fork 279
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 loki.enrich component #2882
base: main
Are you sure you want to change the base?
Conversation
💻 Deploy preview deleted. |
Similar functionality, but not applicable to syslog as of now: https://grafana.com/docs/alloy/latest/reference/stdlib/array/#arraycombine_maps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v-zhuravlev thank you, this looks interesting! Could you please edit the description that this solves #810?
Btw we also have a similar component for traces - otelcol.processor.discovery.
source_label = "LABEL" | ||
|
||
// List of labels to copy from discovered targets to logs | ||
target_labels = ["LABEL", ...] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can think of a more descriptive name. target_labels
could be labels that we got from the discovered targets just for matching but not for addition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about labels_to_copy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edited description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like labels_to_copy
! It's more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll change it then
// Initialize the cache with provided targets | ||
c.refreshCacheFromTargets(args.Targets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if the discovery component will just return an empty map if it hasn't discovered anything yet? Then loki.enrich
would still not work for the first few seconds until the discovery starts working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, possibly. Is there any way to force discovery before component is initialized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
|
||
func init() { | ||
component.Register(component.Registration{ | ||
Name: "loki.enrich", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loki.enrich
sounds like a good name. Initially I thought there should be a reference to discovery
or targets
in the name, but I gave up on that thought because in theory the targets don't have to come from a discovery
component.
PR Description
This PR adds a new
loki.enrich
component that enriches Loki logs with labels fromdiscovery.*
components.The component matches a label from incoming logs against a label from discovered targets, and copies specified labels from the matched target to the log entry.
Should solve #810 .
Features:
Example use cases to ensure best logs-metrics correlation:
Notes to the Reviewer
PR Checklist