-
Notifications
You must be signed in to change notification settings - Fork 1.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
filter_rewrite_tag: add and-combination for rules #2399
base: master
Are you sure you want to change the base?
Conversation
rules in rewrite_tag filter were combined with OR combination. In some usecases an AND-combination is helpful. For instance, when logmessages in kubernetes from customer namespaces should be dropped, which haven't set a special annotation field. Without an AND-combination, two filter section are necessary, to get this done. Configuration example: to each rule a fifth field with true|false can be added. 'true' means, that this rule should be "AND"-combined with the next rule. "false" means default "OR" behaviour, and is not needed. So its full compatible with old filter configuration. ``` [FILTER] Name rewrite_tag Match tail Rule $log ^(1|3)$ newtag_or false false Rule $log ^(.*end)$ newtag_and_1 false true Rule $log ^(1.*)$ newtag_and_2 false false Rule $log ^(2.*)$ newtag_or false ``` Signed-off-by: Michael Voelker <[email protected]>
Example configfiguration fluentbit.conf
/var/tmp/loginput.txt
rewrite_tag result:
|
Debug log
|
description for and-combination for rewrite_tag filter rules PR: fluent/fluent-bit#2399 Signed-off-by: Michael Voelker <[email protected]>
thanks for opening this PR. I think it's not the main purpose of rewrite tag filter to discard records, but rewrite tags only, and optionally discard the original matched ones. If you need to "let pass" records that matches a criteria there are other ways to do it. E.g: consider the following test file with two records: {"log": {"kubernetes": {"msg": "test1", "logme": "yes"}}}
{"log": {"kubernetes": {"msg": "test2"}}} Using tail + grep filter you can accomplish the same thing you need: fluent-bit -R parsers.conf \
-i tail -p path=test.log -p parser=json \
-F grep -p "regex=\$log['kubernetes']['logme'] yes" -m '*' \
-o stdout -p format=json_lines -f 1 output: {"date":1596059959.811035,"log":{"kubernetes":{"msg":"test1","logme":"yes"}}} another way to accomplish the same is using the stream processor, making the input plugin non-routable and creating a new stream that matches a SQL criteria. |
thanks for the reply, I didnt' knew so far, that grep can handle nested fields with this regex syntax. (In grep documentation section is only an example about using filter/nest for this case) But i still don't see, that grep can solve my usecase. Task is to drop messages, that fulfill both conditions: input:
result:
I assume, that the An alternate requirement could be in future, not to drop, but to route them to a seperate output with a customers pool kafka topic, collecting all the 'customer-logs' without a namespace specific kafkatopic (set in annotation loggingkafkatopic) to seperate them from the clusters default kafkatopic. |
rules in rewrite_tag filter were combined with OR combination. In some usecases
an AND-combination is helpful. For instance, when logmessages in kubernetes from
customer namespaces should be dropped, which haven't set a special annotation
field. Without an AND-combination, two filter section are necessary, to get this
done.
Configuration example:
to each rule a fifth field with true|false can be added. 'true' means, that this
rule should be "AND"-combined with the next rule. "false" means default "OR"
behaviour, and is not needed. So its full compatible with old filter configuration.
Signed-off-by: Michael Voelker [email protected]
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:
Documentation
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.