-
Notifications
You must be signed in to change notification settings - Fork 1.8k
filter_nest: add wildcard_exclude config #10112
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Greg Eales <[email protected]>
|
Example config: pipeline:
inputs:
- name: dummy
tag: logs
dummy: |
{
"message": "simple log generated",
"logger": "my.logger",
"level": "INFO",
"hostname": "localhost",
"my_map_of_attributes_1": {
"key_1": "hello, world!",
"key_2": "goodbye, world!"
},
"my_map_of_maps_1": {
"root_key": {
"sub_key_1": "hello, world!",
"sub_key_2": "goodbye, world!"
}
},
"an_unknown_key": "hello, world!",
"another_unknown_key": "goodbye, world!"
}
filters:
- name: nest
match: logs
nest_under: nested
wildcard: '*'
wildcard_exclude:
- message
- logger
- hostname
- level
- 'my_map_of_*'
outputs:
- name: stdout
match: logsThe above will nest keys |
|
Here is some console output, showing how the above example config produces the correct output: |
|
|
||
| if (wildcard_exclude->key_is_dynamic) { | ||
| /* This will negatively match "ABC123" with prefix "ABC*" */ | ||
| if (strncmp(key, wildcard_exclude->key, wildcard_exclude->key_len) == 0) { |
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.
key is not a null terminated string and this comparison can potentially fail. Since klen is set, I recommend comparing first klen == wildcard_exclude->key_len and if it passes then do the strncmp()
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.
FYI, I copy and pasted this bloc of code from wildcards below, and adapted to wildcards_excludes.
As I read it, this part is for "dynamic" matches (where there is a wildcard), so we don't expect the lengths to match. For "non-dynamic" (which follows), it does do a length check already.
However, we could do a check here, something like klen >= wildcard_exclude->key_len, right?
This is to check that ABC123 is a viable match for wildcard ABC*, so we want to check that ABC123 is at least three chars long...
I will add some more unit tests to verify all this 🤞
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 added the klen >= wildcard_exclude->key_len check, and some tests, and it all looks good
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |

Implements #10111 by adding
wildcard_excludeconfig tonestfilter#10111
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.