Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions pipeline/filters/rewrite-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,54 @@
...
[0] from.test_tag.new.fluent.bit.out: [1580436933.000050569, {"tool"=>"fluent", "sub"=>{"s1"=>{"s2"=>"bit"}}}]
```
## Configuration example with multiple rules
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. I f the first and following rule match, the message is retagged with the tag in the last matched rule.

Check warning on line 180 in pipeline/filters/rewrite-tag.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [FluentBit.Spelling] Spelling check: 'retagged'? Raw Output: {"message": "[FluentBit.Spelling] Spelling check: 'retagged'?", "location": {"path": "pipeline/filters/rewrite-tag.md", "range": {"start": {"line": 180, "column": 288}}}, "severity": "INFO"}

Check warning on line 180 in pipeline/filters/rewrite-tag.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [FluentBit.FirstPerson] Avoid first-person pronouns such as 'I '. Raw Output: {"message": "[FluentBit.FirstPerson] Avoid first-person pronouns such as 'I '.", "location": {"path": "pipeline/filters/rewrite-tag.md", "range": {"start": {"line": 180, "column": 233}}}, "severity": "WARNING"}

Check warning on line 180 in pipeline/filters/rewrite-tag.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [FluentBit.FirstPerson] Avoid first-person pronouns such as ' I '. Raw Output: {"message": "[FluentBit.FirstPerson] Avoid first-person pronouns such as ' I '.", "location": {"path": "pipeline/filters/rewrite-tag.md", "range": {"start": {"line": 180, "column": 232}}}, "severity": "WARNING"}

An `AND_COMBINE` in the last rule is ignored.
```text
[SERVICE]
Flush 5
Log_Level info
[INPUT]
Name tail
Tag tail
Path /var/tmp/loginput.txt
[FILTER]
Name rewrite_tag
Match tail
Rule $log ^(1)$ newtag_or false
Rule $log ^(.*and)$ newtag_and_1 false true
Rule $log ^(1.*)$ newtag_and_2 false
Rule $log ^(42)$ newtag_or false
Rule $log ^(9)$ newtag_and_3 false true
[OUTPUT]
Name stdout
Match *
```
inputfile /var/tmp/loginput.txt

Check warning on line 206 in pipeline/filters/rewrite-tag.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [FluentBit.Spelling] Spelling check: 'inputfile'? Raw Output: {"message": "[FluentBit.Spelling] Spelling check: 'inputfile'?", "location": {"path": "pipeline/filters/rewrite-tag.md", "range": {"start": {"line": 206, "column": 1}}}, "severity": "INFO"}
```text
1
2
3
9
10and
10
42
```

The log messages will be rewritten:
```
fluent-bit_1 | [0] tail: [1596050753.241336500, {"log"=>"2"}]
fluent-bit_1 | [1] tail: [1596050753.241356700, {"log"=>"3"}]
fluent-bit_1 | [2] tail: [1596050753.241410100, {"log"=>"10"}]
fluent-bit_1 | [0] newtag_or: [1596050753.237370100, {"log"=>"1"}]
fluent-bit_1 | [1] newtag_or: [1596050753.241427200, {"log"=>"42"}]
fluent-bit_1 | [0] newtag_and_3: [1596050753.241374500, {"log"=>"9"}]
fluent-bit_1 | [0] newtag_and_2: [1596050753.241392800, {"log"=>"10and"}]
```

## Monitoring

Expand Down
Loading