Search code examples
fluent-bit

Fluentbit output file name equal to input file name


I'm using fluentbit file plugin and I would like to configure it so that the file name of the output is equal to the file name of the input. Is something like this possible?

So if input file path = /path/to/file.log Then the file output name will also be file.log

I also have a tag that includes the fileName, is it possible to use regex to get the name?


Solution

  • In fluent bit file output, the file key default value is the tag from input. In tail input plugin, you can add Tag_Regex, e.g. Tag_Regex (?<file_name>[ \w-]+\.) , and use it in tag (Tag <filename>log). The file output will use the tag name, resulting in file name as output.

    [INPUT]
        Name tail
        Path /path/to/file.log
        Tag <file_name>log
        Tag_Regex (?<file_name>[ \w-]+\.)
    [OUTPUT]
        Name file
        Match *
        Path /path/to/