Skip to content

Commit 608cb10

Browse files
committed
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]>
1 parent 9f7fd82 commit 608cb10

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

pipeline/filters/rewrite-tag.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The `rewrite_tag` filter supports the following configuration parameters:
2626

2727
| Key | Description |
2828
| :--- | :--- |
29-
| Rule | Defines the matching criteria and the format of the Tag for the matching record. The Rule format have four components: `KEY REGEX NEW_TAG KEEP`. For more specific details of the Rule format and it composition read the next section. |
29+
| Rule | Defines the matching criteria and the format of the Tag for the matching record. The Rule format have four mandatory components: `KEY REGEX NEW_TAG KEEP` and an optional component: `AND_COMBINE`. For more specific details of the Rule format and it composition read the next section. |
3030
| Emitter\_Name | When the filter emits a record under the new Tag, there is an internal emitter plugin that takes care of the job. Since this emitter expose metrics as any other component of the pipeline, you can use this property to configure an optional name for it. |
3131
| Emitter\_Storage.type | Define a buffering mechanism for the new records created. Note these records are part of the emitter plugin. This option support the values `memory` \(default\) or `filesystem`. If the destination for the new records generated might face backpressure due to latency or slow network, we strongly recommend enabling the `filesystem` mode. |
3232
| Emitter\_Mem\_Buf\_Limit | Set a limit on the amount of memory the tag rewrite emitter can consume if the outputs provide backpressure. The default for this limit is `10M`. The pipeline will pause once the buffer exceeds the value of this setting. For example, if the value is set to `10M` then the pipeline will pause if the buffer exceeds `10M`. The pipeline will remain paused until the output drains the buffer below the `10M` limit. |
@@ -151,6 +151,58 @@ Fluent Bit v1.x.x
151151
...
152152
[0] from.test_tag.new.fluent.bit.out: [1580436933.000050569, {"tool"=>"fluent", "sub"=>{"s1"=>{"s2"=>"bit"}}}]
153153
```
154+
## Configuration Example with many Rules
155+
In case of many rules, they are passed through in order until one rule matches. With`AND_COMBINE`value`true` as optional fifth
156+
component, the rule is combined with the following rule like an 'and' combination. Only if first and following rule match, the message is retagged with the tag in the last matched rule.
157+
An `AND_COMBINE` in the last rule is ignored.
158+
```
159+
[SERVICE]
160+
Flush 5
161+
Log_Level info
162+
163+
[INPUT]
164+
Name tail
165+
Tag tail
166+
Path /var/tmp/loginput.txt
167+
168+
[FILTER]
169+
Name rewrite_tag
170+
Match tail
171+
Rule $log ^(1)$ newtag_or false
172+
Rule $log ^(.*and)$ newtag_and_1 false true
173+
Rule $log ^(1.*)$ newtag_and_2 false
174+
Rule $log ^(42)$ newtag_or false
175+
Rule $log ^(9)$ newtag_and_3 false true
176+
177+
[OUTPUT]
178+
Name stdout
179+
Match *
180+
```
181+
inputfile /var/tmp/loginput.txt
182+
```
183+
1
184+
2
185+
3
186+
9
187+
10and
188+
10
189+
42
190+
```
191+
192+
the logmessages will be rewritten:
193+
```
194+
fluent-bit_1 | [0] tail: [1596050753.241336500, {"log"=>"2"}]
195+
fluent-bit_1 | [1] tail: [1596050753.241356700, {"log"=>"3"}]
196+
fluent-bit_1 | [2] tail: [1596050753.241410100, {"log"=>"10"}]
197+
fluent-bit_1 | [0] newtag_or: [1596050753.237370100, {"log"=>"1"}]
198+
fluent-bit_1 | [1] newtag_or: [1596050753.241427200, {"log"=>"42"}]
199+
fluent-bit_1 | [0] newtag_and_3: [1596050753.241374500, {"log"=>"9"}]
200+
fluent-bit_1 | [0] newtag_and_2: [1596050753.241392800, {"log"=>"10and"}]
201+
```
202+
203+
204+
205+
154206

155207
## Monitoring
156208

0 commit comments

Comments
 (0)