Skip to content

Commit 9393bf7

Browse files
novegitesmerel
authored andcommitted
filter_rewrite_tag: add and-combination for rules (fluent#349)
* filter_rewrite_tag: add and-combination for rules description for and-combination for rewrite_tag filter rules PR: fluent/fluent-bit#2399 Signed-off-by: Michael Voelker <[email protected]> * Apply suggestions from code review Signed-off-by: Lynette Miles <[email protected]> * Apply suggestions from code review Signed-off-by: Lynette Miles <[email protected]> --------- Signed-off-by: Michael Voelker <[email protected]> Signed-off-by: Lynette Miles <[email protected]> Co-authored-by: Lynette Miles <[email protected]> Signed-off-by: Tom <[email protected]>
1 parent d82033f commit 9393bf7

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

pipeline/filters/rewrite-tag.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,54 @@ $ fluent-bit -c example.conf
176176
...
177177
[0] from.test_tag.new.fluent.bit.out: [1580436933.000050569, {"tool"=>"fluent", "sub"=>{"s1"=>{"s2"=>"bit"}}}]
178178
```
179+
## Configuration example with multiple rules
180+
In cases using multiple rules, the rules are passed through in order until one matches. With `AND_COMBINE` using the value `true` as optional fifth component, the rule is combined with the following rule like an 'and' combination. If the first and following rule match, the message is retagged with the tag in the last matched rule.
181+
182+
An `AND_COMBINE` in the last rule is ignored.
183+
```text
184+
[SERVICE]
185+
Flush 5
186+
Log_Level info
187+
188+
[INPUT]
189+
Name tail
190+
Tag tail
191+
Path /var/tmp/loginput.txt
192+
193+
[FILTER]
194+
Name rewrite_tag
195+
Match tail
196+
Rule $log ^(1)$ newtag_or false
197+
Rule $log ^(.*and)$ newtag_and_1 false true
198+
Rule $log ^(1.*)$ newtag_and_2 false
199+
Rule $log ^(42)$ newtag_or false
200+
Rule $log ^(9)$ newtag_and_3 false true
201+
202+
[OUTPUT]
203+
Name stdout
204+
Match *
205+
```
206+
Use the input file `/var/tmp/loginput.txt`:
207+
```text
208+
1
209+
2
210+
3
211+
9
212+
10and
213+
10
214+
42
215+
```
216+
217+
The log messages will be rewritten:
218+
```
219+
fluent-bit_1 | [0] tail: [1596050753.241336500, {"log"=>"2"}]
220+
fluent-bit_1 | [1] tail: [1596050753.241356700, {"log"=>"3"}]
221+
fluent-bit_1 | [2] tail: [1596050753.241410100, {"log"=>"10"}]
222+
fluent-bit_1 | [0] newtag_or: [1596050753.237370100, {"log"=>"1"}]
223+
fluent-bit_1 | [1] newtag_or: [1596050753.241427200, {"log"=>"42"}]
224+
fluent-bit_1 | [0] newtag_and_3: [1596050753.241374500, {"log"=>"9"}]
225+
fluent-bit_1 | [0] newtag_and_2: [1596050753.241392800, {"log"=>"10and"}]
226+
```
179227

180228
## Monitoring
181229

0 commit comments

Comments
 (0)