-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: detect json and logfmt log types #44
base: main
Are you sure you want to change the base?
Conversation
@adamhackl thanks for the PR, appreciate the contribution! I would like to avoid having a module that can continuously grow in size, with more and more conditions. Essentially, The bottom of that module has a very large "catch all" regex that will catch the vast majority of patterns if they aren't already defined. There are only two checks above that, one for klog which is a lot different, and another for zero log which was also different. There is value in detecting that actual format though, to allow for other downstream conditions, reporting, etc. Ideally, this would be the users choice to implement though. What I would purpose or like to see happen is:
Having the component exist in the module does not mean it is used, it still most be invoked/instantiated. This way if a user wants to explicitly detect json formatted logs, they can use that component. The user has the choice of implementing what they want instead of this module applying what would be an ever growing list of conditions within a single module. @erikbaranowski @mattdurham any additional thoughts to add to this? |
@bentonam thanks for the feedback! I like your idea.
The log_type definitely doesn't have a whole lot of use cases aside from being informational. I might actually just drop it instead of exposing it to the users if a lot of the lines are going to be labeled unknown. |
@bentonam I incorporated your suggestions and was able to test ... all seems to work as expected. Hopefully captured your suggestion correctly. This would be a breaking change for anyone already using this component. |
9f029dc
to
5e33de4
Compare
I added sections to detect type and extract level for both
json
andlogfmt
to complement the existingklog
andzerolog
detection. I used the logic that was used in grafana-agent-modules, which seems to work well. The only deviation I made was to add a start of line^
to the regex for logfmt, because without it I got a lot of false alerts (basically anything with an = in it).These don't check for the format pod annotation like the grafana-agent-modules did. That would take some significant rework and personally I like that it auto-detects the type and level.