-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
lowercase processor plugin #3890
Conversation
Thanks for the pull request, I'd like to see how much interest there is in this plugin before moving forward with merging it into master. Can everyone who needs this give it a thumbs up and add a description of how you would use it. |
OK that's a fair plan. I don't know if this is helpful but here's my use case in a bit more detail. I have logs that look a bit like this (I built a file of 1000 records as an easier-on-the-eye example)
And a configuration that looks like this
Curiously I think there's something wrong with the pattern because it only produces 899 points from the file. I don't think it's a problem for the example though. Because case does not match I get this
But adding the lowercase plugin which looks like this
Gives me what I want which is this (apart from 101 missing points, but since it's just an example I don't care)
|
Right now this plugin is very specialized, I wonder if we should make this processor extendable so that we could add more common string processing functions later, which I think would help move this processor into the goldilocks zone: [[processors.strings]]
namepass = "foo"
[[processors.strings.lowercase]]
tag = "method"
# defaults to value, apply operation to key or value
convert = "value"
result_key = "method_lower"
## imaginary operation we could add later:
[[processors.strings.snakecase]]
field = "NetworkPacketIn"
convert = "key" - foo,method=GET, NetworkPacketIn=42i
+ foo,method=GET,method_lower=get network_packet_in=42i Other string functions I can think of are upper, title, camelcase, casefold. |
I've taken a look and I don't see why not. I imagined that you might make a separate plugin for different functions before I really understood how the plugins worked but it doesn't seem so hard now. I concentrated on lowercase because it was one way to solve my problem at the time. Shall I adapt it to work like that but just include lowercase and one other function (to show how it can be extended) for now? |
@bsmaldon Yeah that would be great, thanks |
WOW, I need uppercase plugin (to unify hostname tags). :) |
Some other handy functions might be trim, trim_left and trim_right. |
I've picked this up again but now that I look at it I'm not sure what the rationale for the |
Sounds good, we will probably add a standalone processor for renames and then this plugin can focus on string manipulation. |
I'm opening a new pull request for this because I rebased but don't know how to update this pull request. The updated pull request number is #4476. |
Okay, no problem. (The way you can do this is by force pushing over the old branch: |
My own use case means I need to convert the values of tags from upper case to lower case (or vice versa) because IIS logs I've been working with contain the character case originally expressed in each request, but this means statistics are not aggregated together by the basicstats aggregator.
I tried building and using the regex processor, #3839 , but regex in golang doesn't support the case transformations available in Perl with \L and \U. Everything else about the plugin was a perfect fit so I copied its structure and want to credit @44px for most of the hard work. The plugin just calls strings.ToLower on the tags and fields specified.
Configuration Example
Source metric from logparser
Results
Required for all PRs: