-
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
Support for extracting attributes/labels from log body #14938
Comments
Pinging code owners: @gramidt @gouthamve @jpkrohling @kovrus @mar4uk. See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Pinging code owners: @boostchicken. See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Pinging code owners: @djaglowski. See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I've added a minimal version here(#15282) which modifies |
@lsampras, please take a look at #9410. We have some fairly robust capabilities to parse and manipulate logs, but only in receivers that use In the case of plucking a value from a json log, I think we should have a function that parses the json and assigns the resulting object to a specified field. Separately, we should have a function that moves values from one field to another. This kind of design allows us to compose functions. |
After merging the promtail receiver pipeline_stages will be available the same way they are available in promtail itself.
So when using promtail receiver -> loki exporter labels will work out of the box. |
It is intended that |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
We've had discussion recently around how to handle functions and converters (previously factory functions) that share the same functionality (see #16571) This PR suggests a different approach that should reduce the need to chain converters/functions. Before we chained converters together because OTTL had no place to store data except for the telemetry payload itself. While attributes could be used, it results in the need for cleanup and potentially unwanted transformations based on condition resolution. This PR introduces the concept of tmp to the logs contexts (and future contexts if we like the solution) that statements can use as a "staging" location for complex transformations. Before to handle situations like the one in #14938 we would have to chain together functions. Pretending we had KeepKeys converter the statement would look like merge_maps(attributes, KeepKeys(ParseJSON(body), ["log_type"]), "upsert"). These types of statements are tricky to write and can difficult to comprehend, especially for new users. Each Converter we add on increased the burden. Adding a single extra function, like Flatten, really makes a difference: merge_maps(attributes, Flatten(KeepKeys(ParseJSON(body), ["log_type"]), "."), "upsert") Co-authored-by: Evan Bradley <[email protected]>
@lsampras this capability should be available via the next release of the collector via the |
Is your feature request related to a problem? Please describe.
I wanna set loki labels for my logs based on a key-value pair in my JSON formatted logs,
we provide an option to set loki labels from attributes but I'm not able to extract the body value to an attribute...
E.g
assuming the logs to be something like
I wanna extract the the log_type and set it as a loki label...
Promtail supports this behaviour via its pipeline_stages configuration
Describe the solution you'd like
I see that we already have the attribute processor which supports setting loki labels and adding context based or static attributes,
we also have the transform processor which can be extended to read/parse from log bodies
I think it would be appropriate to extend the behaviour for one of these processors..
Although not sure if this requirement is loki specific (Since most logging solutions index the body and don't need an explicit label) and needs to be implemented in the loki exporter...
Describe alternatives you've considered
For now the alternatives seem to be either not adding these labels (which would lead to inefficient queries in loki) or using another tool (maybe kafka) to handle this processing...
Additional context
No response
The text was updated successfully, but these errors were encountered: