3

FluentBit - Is there a way to Truncate the Logs if they are lets say greater that 1500 characters???

Do not want to have like the entire stack Trace printed....

Is there a config for this???

1 Answers1

2

You could limit the number of characters to get in a regex Parser, through a capture group and a range.

Example:

If you have this line of log

2021-07-25T13:39:00 INFO - Method foo() called with parameter "bar"

You can accomplish the truncation with

[PARSER]
    Name   log_parser
    Format regex
    Regex  ^(?<time>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\s+(?<level>\w+)\s+-\s+(?<message>.{0,20}).*$

In this way, up to 20 characters will be captured, so message will be:

Method foo() called

dems98
  • 814
  • 3
  • 9
  • 22