All pages
Powered by GitBook
1 of 12

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Classic mode

Variables

Fluent Bit supports the usage of environment variables in any value associated to a key when using a configuration file.

The variables are case sensitive and can be used in the following format:

${MY_VARIABLE}

When Fluent Bit starts, the configuration reader will detect any request for ${MY_VARIABLE} and will try to resolve its value.

When Fluent Bit is running under systemd (using the official packages), environment variables can be set in the following files:

  • /etc/default/fluent-bit (Debian based system)

  • /etc/sysconfig/fluent-bit (Others)

These files are ignored if they do not exist.

Example

Create the following configuration file (fluent-bit.conf):

Open a terminal and set the environment variable:

The above command set the 'stdout' value to the variable MY_OUTPUT.

Run Fluent Bit with the recently created configuration file:

As you can see the service worked properly as the configuration was valid.

Format and Schema

Fluent Bit might optionally use a configuration file to define how the service will behave.

Before proceeding we need to understand how the configuration schema works.

The schema is defined by three concepts:

  • Sections

  • Entries: Key/Value

  • Indented Configuration Mode

A simple example of a configuration file is as follows:

Sections

A section is defined by a name or title inside brackets. Looking at the example above, a Service section has been set using [SERVICE] definition. Section rules:

  • All section content must be indented (4 spaces ideally).

  • Multiple sections can exist on the same file.

  • A section is expected to have comments and entries, it cannot be empty.

  • Any commented line under a section, must be indented too.

Entries: Key/Value

A section may contain Entries, an entry is defined by a line of text that contains a Key and a Value, using the above example, the [SERVICE] section contains two entries, one is the key Daemon with value off and the other is the key Log_Level with the value debug. Entries rules:

  • An entry is defined by a key and a value.

  • A key must be indented.

  • A key must contain a value which ends in the breakline.

  • Multiple keys with the same name can exist.

Also commented lines are set prefixing the # character, those lines are not processed but they must be indented too.

Indented Configuration Mode

Fluent Bit configuration files are based in a strict Indented Mode, that means that each configuration file must follow the same pattern of alignment from left to right when writing text. By default an indentation level of four spaces from left to right is suggested. Example:

As you can see there are two sections with multiple entries and comments, note also that empty lines are allowed and they do not need to be indented.

YAML Configuration

YAML configuration feature was introduced since FLuent Bit version 1.9 as experimental, and it is production ready since Fluent Bit 2.0.

[SERVICE]
    Flush        1
    Daemon       Off
    Log_Level    info

[INPUT]
    Name cpu
    Tag  cpu.local

[OUTPUT]
    Name  ${MY_OUTPUT}
    Match *
$ export MY_OUTPUT=stdout

End-of-line comments are not supported, only full-line comments.

$ bin/fluent-bit -c fluent-bit.conf
Fluent Bit v1.4.0
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2020/03/03 12:25:25] [ info] [engine] started
[0] cpu.local: [1491243925, {"cpu_p"=>1.750000, "user_p"=>1.750000, "system_p"=>0.000000, "cpu0.p_cpu"=>3.000000, "cpu0.p_user"=>2.000000, "cpu0.p_system"=>1.000000, "cpu1.p_cpu"=>0.000000, "cpu1.p_user"=>0.000000, "cpu1.p_system"=>0.000000, "cpu2.p_cpu"=>4.000000, "cpu2.p_user"=>4.000000, "cpu2.p_system"=>0.000000, "cpu3.p_cpu"=>1.000000, "cpu3.p_user"=>1.000000, "cpu3.p_system"=>0.000000}]
[SERVICE]
    # This is a commented line
    Daemon    off
    log_level debug
[FIRST_SECTION]
    # This is a commented line
    Key1  some value
    Key2  another value
    # more comments

[SECOND_SECTION]
    KeyN  3.14

Upstream Servers

It's common that Fluent Bit output plugins aims to connect to external services to deliver the logs over the network, this is the case of HTTP, Elasticsearch and Forward within others. Being able to connect to one node (host) is normal and enough for more of the use cases, but there are other scenarios where balancing across different nodes is required. The Upstream feature provides such capability.

An Upstream defines a set of nodes that will be targeted by an output plugin, by the nature of the implementation an output plugin must support the Upstream feature. The following plugin(s) have Upstream support:

  • Forward

The current balancing mode implemented is round-robin.

Configuration

To define an Upstream it's required to create an specific configuration file that contains an UPSTREAM and one or multiple NODE sections. The following table describe the properties associated to each section. Note that all of them are mandatory:

Section
Key
Description

Nodes and specific plugin configuration

A Node might contain additional configuration keys required by the plugin, on that way we provide enough flexibility for the output plugin, a common use case is Forward output where if TLS is enabled, it requires a shared key (more details in the example below).

Nodes and TLS (Transport Layer Security)

In addition to the properties defined in the table above, the network operations against a defined node can optionally be done through the use of TLS for further encryption and certificates use.

The TLS options available are described in the section and can be added to the any Node section.

Configuration File Example

The following example defines an Upstream called forward-balancing which aims to be used by Forward output plugin, it register three Nodes:

  • node-1: connects to 127.0.0.1:43000

  • node-2: connects to 127.0.0.1:44000

  • node-3: connects to 127.0.0.1:45000 using TLS without verification. It also defines a specific configuration option required by Forward output called shared_key.

Note that every Upstream definition must exists on it own configuration file in the file system. Adding multiple Upstreams in the same file or different files is not allowed.

port

TCP port of the target service.

UPSTREAM

name

Defines a name for the Upstream in question.

NODE

name

Defines a name for the Node in question.

host

IP address or hostname of the target host.

TLS/SSL

[UPSTREAM]
    name       forward-balancing

[NODE]
    name       node-1
    host       127.0.0.1
    port       43000

[NODE]
    name       node-2
    host       127.0.0.1
    port       44000

[NODE]
    name       node-3
    host       127.0.0.1
    port       45000
    tls        on
    tls.verify off
    shared_key secret

Configuring Fluent Bit

Currently, Fluent Bit supports two configuration formats:

  • Classic mode.

  • Yaml. (YAML configuration is production ready since Fluent Bit 2.0.)

CLI flags

Fluent Bit also supports a CLI interface with various flags matching up to the configuration options available.

$ docker run --rm -it fluent/fluent-bit --help
Usage: /fluent-bit/bin/fluent-bit [OPTION]

Available Options
  -b  --storage_path=PATH specify a storage buffering path
  -c  --config=FILE       specify an optional configuration file
  -d, --daemon            run Fluent Bit in background mode
  -D, --dry-run           dry run
  -f, --flush=SECONDS     flush timeout in seconds (default: 1)
  -C, --custom=CUSTOM     enable a custom plugin
  -i, --input=INPUT       set an input
  -F  --filter=FILTER     set a filter
  -m, --match=MATCH       set plugin match, same as '-p match=abc'
  -o, --output=OUTPUT     set an output
  -p, --prop="A=B"        set plugin configuration property
  -R, --parser=FILE       specify a parser configuration file
  -e, --plugin=FILE       load an external plugin (shared lib)
  -l, --log_file=FILE     write log info to a file
  -t, --tag=TAG           set plugin tag, same as '-p tag=abc'
  -T, --sp-task=SQL       define a stream processor task
  -v, --verbose           increase logging verbosity (default: info)
  -w, --workdir           set the working directory
  -H, --http              enable monitoring HTTP server
  -P, --port              set HTTP server TCP port (default: 2020)
  -s, --coro_stack_size   set coroutines stack size in bytes (default: 24576)
  -q, --quiet             quiet mode
  -S, --sosreport         support report for Enterprise customers
  -V, --version           show version number
  -h, --help              print this help

Inputs
  cpu                     CPU Usage
  mem                     Memory Usage
  thermal                 Thermal
  kmsg                    Kernel Log Buffer
  proc                    Check Process health
  disk                    Diskstats
  systemd                 Systemd (Journal) reader
  netif                   Network Interface Usage
  docker                  Docker containers metrics
  docker_events           Docker events
  node_exporter_metrics   Node Exporter Metrics (Prometheus Compatible)
  fluentbit_metrics       Fluent Bit internal metrics
  prometheus_scrape       Scrape metrics from Prometheus Endpoint
  tail                    Tail files
  dummy                   Generate dummy data
  dummy_thread            Generate dummy data in a separate thread
  head                    Head Input
  health                  Check TCP server health
  http                    HTTP
  collectd                collectd input plugin
  statsd                  StatsD input plugin
  opentelemetry           OpenTelemetry
  nginx_metrics           Nginx status metrics
  serial                  Serial input
  stdin                   Standard Input
  syslog                  Syslog
  tcp                     TCP
  mqtt                    MQTT, listen for Publish messages
  forward                 Fluentd in-forward
  random                  Random

Filters
  alter_size              Alter incoming chunk size
  aws                     Add AWS Metadata
  checklist               Check records and flag them
  record_modifier         modify record
  throttle                Throttle messages using sliding window algorithm
  type_converter          Data type converter
  kubernetes              Filter to append Kubernetes metadata
  modify                  modify records by applying rules
  multiline               Concatenate multiline messages
  nest                    nest events by specified field values
  parser                  Parse events
  expect                  Validate expected keys and values
  grep                    grep events by specified field values
  rewrite_tag             Rewrite records tags
  lua                     Lua Scripting Filter
  stdout                  Filter events to STDOUT
  geoip2                  add geoip information to records
  nightfall               scans records for sensitive content

Outputs
  azure                   Send events to Azure HTTP Event Collector
  azure_blob              Azure Blob Storage
  azure_kusto             Send events to Kusto (Azure Data Explorer)
  bigquery                Send events to BigQuery via streaming insert
  counter                 Records counter
  datadog                 Send events to DataDog HTTP Event Collector
  es                      Elasticsearch
  exit                    Exit after a number of flushes (test purposes)
  file                    Generate log file
  forward                 Forward (Fluentd protocol)
  http                    HTTP Output
  influxdb                InfluxDB Time Series
  logdna                  LogDNA
  loki                    Loki
  kafka                   Kafka
  kafka-rest              Kafka REST Proxy
  nats                    NATS Server
  nrlogs                  New Relic
  null                    Throws away events
  opensearch              OpenSearch
  plot                    Generate data file for GNU Plot
  pgsql                   PostgreSQL
  skywalking              Send logs into log collector on SkyWalking OAP
  slack                   Send events to a Slack channel
  splunk                  Send events to Splunk HTTP Event Collector
  stackdriver             Send events to Google Stackdriver Logging
  stdout                  Prints events to STDOUT
  syslog                  Syslog
  tcp                     TCP Output
  td                      Treasure Data
  flowcounter             FlowCounter
  gelf                    GELF Output
  websocket               Websocket
  cloudwatch_logs         Send logs to Amazon CloudWatch
  kinesis_firehose        Send logs to Amazon Kinesis Firehose
  kinesis_streams         Send logs to Amazon Kinesis Streams
  opentelemetry           OpenTelemetry
  prometheus_exporter     Prometheus Exporter
  prometheus_remote_write Prometheus remote write
  s3                      Send to S3

Unit Sizes

Certain configuration directives in Fluent Bit refer to unit sizes such as when defining the size of a buffer or specific limits, we can find these in plugins like Tail Input, Forward Input or in generic properties like Mem_Buf_Limit.

Starting from Fluent Bit v0.11.10, all unit sizes have been standardized across the core and plugins, the following table describes the options that can be used and what they mean:

Suffix
Description
Example

When a suffix is not specified, it's assumed that the value given is a bytes representation.

Specifying a value of 32000, means 32000 bytes

Commands

Configuration files must be flexible enough for any deployment need, but they must keep a clean and readable format.

Fluent Bit Commands extends a configuration file with specific built-in features. The list of commands available as of Fluent Bit 0.12 series are:

Command
Prototype
Description

k, K, KB, kb

Kilobyte: a unit of memory equal to 1,000 bytes.

32k means 32000 bytes.

m, M, MB, mb

Megabyte: a unit of memory equal to 1,000,000 bytes

1M means 1000000 bytes

g, G, GB, gb

Gigabyte: a unit of memory equal to 1,000,000,000 bytes

1G means 1000000000 bytes

Set a configuration variable

@INCLUDE Command

Configuring a logging pipeline might lead to an extensive configuration file. In order to maintain a human-readable configuration, it's suggested to split the configuration in multiple files.

The @INCLUDE command allows the configuration reader to include an external configuration file, e.g:

The above example defines the main service configuration file and also include two files to continue the configuration:

inputs.conf

outputs.conf

Note that despites the order of inclusion, Fluent Bit will ALWAYS respect the following order:

  • Service

  • Inputs

  • Filters

  • Outputs

@SET Command

Fluent Bit supports configuration variables, one way to expose this variables to Fluent Bit is through setting a Shell environment variable, the other is through the @SET command.

The @SET command can only be used at root level of each line, meaning it cannot be used inside a section, e.g:

@INCLUDE

@INCLUDE FILE

Include a configuration file

@SET

@SET KEY=VAL

[SERVICE]
    Flush 1

@INCLUDE inputs.conf
@INCLUDE outputs.conf
[INPUT]
    Name cpu
    Tag  mycpu

[INPUT]
    Name tail
    Path /var/log/*.log
    Tag  varlog.*
[OUTPUT]
    Name   stdout
    Match  mycpu

[OUTPUT]
    Name            es
    Match           varlog.*
    Host            127.0.0.1
    Port            9200
    Logstash_Format On
@SET my_input=cpu
@SET my_output=stdout

[SERVICE]
    Flush 1

[INPUT]
    Name ${my_input}

[OUTPUT]
    Name ${my_output}

Record Accessor

A full feature set to access content of your records

Fluent Bit works internally with structured records and it can be composed of an unlimited number of keys and values. Values can be anything like a number, string, array, or a map.

Having a way to select a specific part of the record is critical for certain core functionalities or plugins, this feature is called Record Accessor.

consider Record Accessor a simple grammar to specify record content and other miscellaneous values.

Format

A record accessor rule starts with the character $. Using the structured content above as an example the following table describes how to access a record:

The following table describe some accessing rules and the expected returned value:

Format
Accessed Value

If the accessor key does not exist in the record like the last example $labels['undefined'] , the operation is simply omitted, no exception will occur.

Usage Example

The feature is enabled on a per plugin basis, not all plugins enable this feature. As an example consider a configuration that aims to filter records using that only matches where labels have a color blue:

The file content to process in test.log is the following:

Running Fluent Bit with the configuration above the output will be:

Limitations of record_accessor templating

The Fluent Bit record_accessor library has a limitation in the characters that can separate template variables- only dots and commas (. and ,) can come after a template variable. This is because the templating library must parse the template and determine the end of a variable.

The following would be invalid templates because the two template variables are not separated by commas or dots:

  • $TaskID-$ECSContainerName

  • $TaskID/$ECSContainerName

  • $TaskID_$ECSContainerName

However, the following are valid:

  • $TaskID.$ECSContainerName

  • $TaskID.ecs_resource.$ECSContainerName

  • $TaskID.fooo.$ECSContainerName

And the following are valid since they only contain one template variable with nothing after it:

  • fooo$TaskID

  • fooo____$TaskID

  • fooo/bar$TaskID

Multiline Parsing

In an ideal world, applications might log their messages within a single line, but in reality applications generate multiple log messages that sometimes belong to the same context. But when is time to process such information it gets really complex. Consider application stack traces which always have multiple log lines.

Starting from Fluent Bit v1.8, we have implemented a unified Multiline core functionality to solve all the user corner cases. In this section, you will learn about the features and configuration options available.

Concepts

The Multiline parser engine exposes two ways to configure and use the functionality:

$TaskIDfooo$ECSContainerName

$log

"some message"

$labels['color']

"blue"

$labels['project']['env']

"production"

$labels['unset']

null

$labels['undefined']

grep
{
  "log": "some message",
  "stream": "stdout",
  "labels": {
     "color": "blue", 
     "unset": null,
     "project": {
         "env": "production"
      }
  }
}
[SERVICE]
    flush        1
    log_level    info
    parsers_file parsers.conf

[INPUT]
    name      tail
    path      test.log
    parser    json

[FILTER]
    name      grep
    match     *
    regex     $labels['color'] ^blue$

[OUTPUT]
    name      stdout
    match     *
    format    json_lines
{"log": "message 1", "labels": {"color": "blue"}}
{"log": "message 2", "labels": {"color": "red"}}
{"log": "message 3", "labels": {"color": "green"}}
{"log": "message 4", "labels": {"color": "blue"}}
$ bin/fluent-bit -c fluent-bit.conf 
Fluent Bit v1.x.x
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2020/09/11 16:11:07] [ info] [engine] started (pid=1094177)
[2020/09/11 16:11:07] [ info] [storage] version=1.0.5, initializing...
[2020/09/11 16:11:07] [ info] [storage] in-memory
[2020/09/11 16:11:07] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128
[2020/09/11 16:11:07] [ info] [sp] stream processor started
[2020/09/11 16:11:07] [ info] inotify_fs_add(): inode=55716713 watch_fd=1 name=test.log
{"date":1599862267.483684,"log":"message 1","labels":{"color":"blue"}}
{"date":1599862267.483692,"log":"message 4","labels":{"color":"blue"}}

Built-in multiline parser

  • Configurable multiline parser

  • Built-in Multiline Parsers

    Without any extra configuration, Fluent Bit exposes certain pre-configured parsers (built-in) to solve specific multiline parser cases, e.g:

    Parser
    Description

    docker

    Process a log entry generated by a Docker container engine. This parser supports the concatenation of log entries split by Docker.

    cri

    Process a log entry generated by CRI-O container engine. Same as the docker parser, it supports concatenation of log entries

    go

    Process log entries generated by a Go based language application and perform concatenation if multiline messages are detected.

    python

    Process log entries generated by a Python based language application and perform concatenation if multiline messages are detected.

    java

    Process log entries generated by a Google Cloud Java language application and perform concatenation if multiline messages are detected.

    Configurable Multiline Parsers

    Besides the built-in parsers listed above, through the configuration files is possible to define your own Multiline parsers with their own rules.

    A multiline parser is defined in a parsers configuration file by using a [MULTILINE_PARSER] section definition. The Multiline parser must have a unique name and a type plus other configured properties associated with each type.

    To understand which Multiline parser type is required for your use case you have to know beforehand what are the conditions in the content that determines the beginning of a multiline message and the continuation of subsequent lines. We provide a regex based configuration that supports states to handle from the most simple to difficult cases.

    Property
    Description
    Default

    name

    Specify a unique name for the Multiline Parser definition. A good practice is to prefix the name with the word multiline_ to avoid confusion with normal parser's definitions.

    type

    Set the multiline mode, for now, we support the type regex.

    parser

    Name of a pre-defined parser that must be applied to the incoming content before applying the regex rule. If no parser is defined, it's assumed that's a raw text and not a structured message.

    Note: when a parser is applied to a raw text, then the regex is applied against a specific key of the structured message by using the key_content configuration property (see below).

    Lines and States

    Before start configuring your parser you need to know the answer to the following questions:

    1. What is the regular expression (regex) that matches the first line of a multiline message ?

    2. What are the regular expressions (regex) that match the continuation lines of a multiline message ?

    When matching regex, we have to define states, some states define the start of a multiline message while others are states for the continuation of multiline messages. You can have multiple continuation states definitions to solve complex cases.

    The first regex that matches the start of a multiline message is called start_state, then other regexes continuation lines can have different state names.

    Rules Definition

    A rule specifies how to match a multiline pattern and perform the concatenation. A rule is defined by 3 specific components:

    1. state name

    2. regular expression pattern

    3. next state

    A rule might be defined as follows (comments added to simplify the definition) :

    In the example above, we have defined two rules, each one has its own state name, regex patterns, and the next state name. Every field that composes a rule must be inside double quotes.

    The first rule of state name must always be start_state, and the regex pattern must match the first line of a multiline message, also a next state must be set to specify how the possible continuation lines would look like.

    To simplify the configuration of regular expressions, you can use the Rubular web site. We have posted an example by using the regex described above plus a log line that matches the pattern: https://rubular.com/r/NDuyKwlTGOvq2g

    Configuration Example

    The following example provides a full Fluent Bit configuration file for multiline parsing by using the definition explained above.

    The following example files can be located at: https://github.com/fluent/fluent-bit/tree/master/documentation/examples/multiline/regex-001

    Example files content:

    This is the primary Fluent Bit configuration file. It includes the parsers_multiline.conf and tails the file test.log by applying the multiline parser multiline-regex-test. Then it sends the processing to the standard output.

    This second file defines a multiline parser for the example.

    An example file with multiline content:

    By running Fluent Bit with the given configuration file you will obtain:

    The lines that did not match a pattern are not considered as part of the multiline message, while the ones that matched the rules were concatenated properly.

    Limitations

    The multiline parser is a very powerful feature, but it has some limitations that you should be aware of:

    • The multiline parser is not affected by the buffer_max_size configuration option, allowing the composed log record to grow beyond this size. Hence, the skip_long_lines option will not be applied to multiline messages.

    • It is not possible to get the time key from the body of the multiline message. However, it can be extracted and set as a new key by using a filter.

    Get structured data from multiline message

    Fluent-bit supports /pat/m option. It allows . matches a new line. It is useful to parse multiline log.

    The following example is to get date and message from concatenated log.

    Example files content:

    This is the primary Fluent Bit configuration file. It includes the parsers_multiline.conf and tails the file test.log by applying the multiline parser multiline-regex-test. It also parses concatenated log by applying parser named-capture-test. Then it sends the processing to the standard output.

    This second file defines a multiline parser for the example.

    An example file with multiline content:

    By running Fluent Bit with the given configuration file you will obtain:

    [SERVICE]
        flush        1
        log_level    info
        parsers_file parsers_multiline.conf
    
    [INPUT]
        name             tail
        path             test.log
        read_from_head   true
        multiline.parser multiline-regex-test
    
    [OUTPUT]
        name             stdout
        match            *
    [MULTILINE_PARSER]
        name          multiline-regex-test
        type          regex
        flush_timeout 1000
        #
        # Regex rules for multiline parsing
        # ---------------------------------
        #
        # configuration hints:
        #
        #  - first state always has the name: start_state
        #  - every field in the rule must be inside double quotes
        #
        # rules |   state name  | regex pattern                  | next state
        # ------|---------------|--------------------------------------------
        rule      "start_state"   "/([a-zA-Z]+ \d+ \d+\:\d+\:\d+)(.*)/"  "cont"
        rule      "cont"          "/^\s+at.*/"                     "cont"
    single line...
    Dec 14 06:41:08 Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
        at com.myproject.module.MyProject.badMethod(MyProject.java:22)
        at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
        at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
        at com.myproject.module.MyProject.someMethod(MyProject.java:10)
        at com.myproject.module.MyProject.main(MyProject.java:6)
    another line...
    
    [SERVICE]
        flush        1
        log_level    info
        parsers_file parsers_multiline.conf
    
    [INPUT]
        name             tail
        path             test.log
        read_from_head   true
        multiline.parser multiline-regex-test
    
    [FILTER]
        name             parser
        match            *
        key_name         log
        parser           named-capture-test
    
    [OUTPUT]
        name             stdout
        match            *
    [MULTILINE_PARSER]
        name          multiline-regex-test
        type          regex
        flush_timeout 1000
        #
        # Regex rules for multiline parsing
        # ---------------------------------
        #
        # configuration hints:
        #
        #  - first state always has the name: start_state
        #  - every field in the rule must be inside double quotes
        #
        # rules |   state name  | regex pattern                  | next state
        # ------|---------------|--------------------------------------------
        rule      "start_state"   "/([a-zA-Z]+ \d+ \d+\:\d+\:\d+)(.*)/"  "cont"
        rule      "cont"          "/^\s+at.*/"                     "cont"
    
    [PARSER]
        Name named-capture-test
        Format regex
        Regex /^(?<date>[a-zA-Z]+ \d+ \d+\:\d+\:\d+) (?<message>.*)/m
    single line...
    Dec 14 06:41:08 Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
        at com.myproject.module.MyProject.badMethod(MyProject.java:22)
        at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
        at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
        at com.myproject.module.MyProject.someMethod(MyProject.java:10)
        at com.myproject.module.MyProject.main(MyProject.java:6)
    another line...
    
    # rules   |   state name   | regex pattern                   | next state
    # --------|----------------|---------------------------------------------
    rule         "start_state"   "/([a-zA-Z]+ \d+ \d+\:\d+\:\d+)(.*)/"   "cont"
    rule         "cont"          "/^\s+at.*/"                      "cont"
    $ fluent-bit -c fluent-bit.conf 
    
    [0] tail.0: [0.000000000, {"log"=>"single line...
    "}]
    [1] tail.0: [1626634867.472226330, {"log"=>"Dec 14 06:41:08 Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
        at com.myproject.module.MyProject.badMethod(MyProject.java:22)
        at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
        at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
        at com.myproject.module.MyProject.someMethod(MyProject.java:10)
        at com.myproject.module.MyProject.main(MyProject.java:6)
    "}]
    [2] tail.0: [1626634867.472226330, {"log"=>"another line...
    "}]
    
    $ fluent-bit -c fluent-bit.conf
    
    [0] tail.0: [1669160706.737650473, {"log"=>"single line...
    "}]
    [1] tail.0: [1669160706.737657687, {"date"=>"Dec 14 06:41:08", "message"=>"Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting!
        at com.myproject.module.MyProject.badMethod(MyProject.java:22)
        at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18)
        at com.myproject.module.MyProject.anotherMethod(MyProject.java:14)
        at com.myproject.module.MyProject.someMethod(MyProject.java:10)
        at com.myproject.module.MyProject.main(MyProject.java:6)
    "}]
    [2] tail.0: [1669160706.737657687, {"log"=>"another line...
    "}]

    key_content

    For an incoming structured message, specify the key that contains the data that should be processed by the regular expression and possibly concatenated.

    flush_timeout

    Timeout in milliseconds to flush a non-terminated multiline buffer. Default is set to 5 seconds.

    5s

    rule

    Configure a rule to match a multiline pattern. The rule has a specific format described below. Multiple rules can be defined.

    Configuration File

    This page describes the main configuration file used by Fluent Bit

    One of the ways to configure Fluent Bit is using a main configuration file. Fluent Bit allows to use one configuration file which works at a global scope and uses the Format and Schema defined previously.

    The main configuration file supports four types of sections:

    • Service

    • Input

    • Filter

    • Output

    In addition, it's also possible to split the main configuration file in multiple files using the feature to include external files:

    • Include File

    Service

    The Service section defines global properties of the service, the keys available as of this version are described in the following table:

    Key
    Description
    Default Value

    The following is an example of a SERVICE section:

    For scheduler and retry details, please check there:

    Input

    An INPUT section defines a source (related to an input plugin), here we will describe the base configuration for each INPUT section. Note that each input plugin may add it own configuration keys:

    Key
    Description

    The Name is mandatory and it let Fluent Bit know which input plugin should be loaded. The Tag is mandatory for all plugins except for the input forward plugin (as it provides dynamic tags).

    Example

    The following is an example of an INPUT section:

    Filter

    A FILTER section defines a filter (related to an filter plugin), here we will describe the base configuration for each FILTER section. Note that each filter plugin may add it own configuration keys:

    Key
    Description

    The Name is mandatory and it let Fluent Bit know which filter plugin should be loaded. The Match or Match_Regex is mandatory for all plugins. If both are specified, Match_Regex takes precedence.

    Example

    The following is an example of an FILTER section:

    Output

    The OUTPUT section specify a destination that certain records should follow after a Tag match. Currently, Fluent Bit can route up to 256 OUTPUT plugins. The configuration support the following keys:

    Key
    Description

    Example

    The following is an example of an OUTPUT section:

    Example: collecting CPU metrics

    The following configuration file example demonstrates how to collect CPU metrics and flush the results every five seconds to the standard output:

    Visualize

    You can also visualize Fluent Bit INPUT, FILTER, and OUTPUT configuration via

    Include File

    To avoid complicated long configuration files is better to split specific parts in different files and call them (include) from one main file.

    Starting from Fluent Bit 0.12 the new configuration command @INCLUDE has been added and can be used in the following way:

    The configuration reader will try to open the path somefile.conf, if not found, it will assume it's a relative path based on the path of the base configuration file, e.g:

    • Main configuration file path: /tmp/main.conf

    • Included file: somefile.conf

    • Fluent Bit will try to open somefile.conf, if it fails it will try /tmp/somefile.conf.

    The @INCLUDE command only works at top-left level of the configuration line, it cannot be used inside sections.

    Wildcard character (*) is supported to include multiple files, e.g:

    Note files matching the wildcard character are included unsorted. If plugins ordering between files need to be preserved, the files should be included explicitly.

    Set the primary transport layer protocol used by the asynchronous DNS resolver which can be overridden on a per plugin basis

    UDP

    log_file

    Absolute path for an optional log file. By default all logs are redirected to the standard error interface (stderr).

    log_level

    Set the logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Values are accumulative, e.g: if 'debug' is set, it will include error, warning, info and debug. Note that trace mode is only available if Fluent Bit was built with the WITH_TRACE option enabled.

    info

    parsers_file

    Path for a parsers configuration file. Multiple Parsers_File entries can be defined within the section.

    plugins_file

    Path for a plugins configuration file. A plugins configuration file allows to define paths for external plugins, for an example .

    streams_file

    Path for the Stream Processor configuration file. To learn more about Stream Processing configuration go .

    http_server

    Enable built-in HTTP Server

    Off

    http_listen

    Set listening interface for HTTP Server when it's enabled

    0.0.0.0

    http_port

    Set TCP Port for the HTTP Server

    2020

    coro_stack_size

    Set the coroutines stack size in bytes. The value must be greater than the page size of the running system. Don't set too small value (say 4096), or coroutine threads can overrun the stack buffer. Do not change the default value of this parameter unless you know what you are doing.

    24576

    scheduler.cap

    Set a maximum retry time in second. The property is supported from v1.8.7.

    2000

    scheduler.base

    Set a base of exponential backoff. The property is supported from v1.8.7.

    5

    json.convert_nan_to_null

    If enabled, NaN is converted to null when fluent-bit converts msgpack to json.

    false

    sp.convert_from_str_to_num

    If enabled, Stream processor converts from number string to number type.

    true

    flush

    Set the flush time in seconds.nanoseconds. The engine loop uses a Flush timeout to define when is required to flush the records ingested by input plugins through the defined output plugins.

    5

    grace

    Set the grace time in seconds as Integer value. The engine loop uses a Grace timeout to define wait time on exit

    5

    daemon

    Boolean value to set if Fluent Bit should run as a Daemon (background) or not. Allowed values are: yes, no, on and off. note: If you are using a Systemd based unit as the one we provide in our packages, do not turn on this option.

    Off

    Name

    Name of the input plugin.

    Tag

    Tag name associated to all records coming from this plugin.

    Log_Level

    Set the plugin's logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Defaults to the SERVICE section's Log_Level.

    Name

    Name of the filter plugin.

    Match

    A pattern to match against the tags of incoming records. It's case sensitive and support the star (*) character as a wildcard.

    Match_Regex

    A regular expression to match against the tags of incoming records. Use this option if you want to use the full regex syntax.

    Log_Level

    Set the plugin's logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Defaults to the SERVICE section's Log_Level.

    Name

    Name of the output plugin.

    Match

    A pattern to match against the tags of incoming records. It's case sensitive and support the star (*) character as a wildcard.

    Match_Regex

    A regular expression to match against the tags of incoming records. Use this option if you want to use the full regex syntax.

    Log_Level

    Set the plugin's logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Defaults to the SERVICE section's Log_Level.

    scheduling and retries
    Calyptia

    dns.mode

    [SERVICE]
        Flush           5
        Daemon          off
        Log_Level       debug
    [INPUT]
        Name cpu
        Tag  my_cpu
    [FILTER]
        Name  grep
        Match *
        Regex log aa
    [OUTPUT]
        Name  stdout
        Match my*cpu
    [SERVICE]
        Flush     5
        Daemon    off
        Log_Level debug
    
    [INPUT]
        Name  cpu
        Tag   my_cpu
    
    [OUTPUT]
        Name  stdout
        Match my*cpu
    @INCLUDE somefile.conf
    @INCLUDE input_*.conf
    see here
    here

    Configuration File

    This page describes the yaml configuration file used by Fluent Bit

    One of the ways to configure Fluent Bit is using a YAML configuration file that works at a global scope.

    The YAML configuration file supports the following sections:

    • Env

    • Includes

    • Service

    • Pipeline

      • Inputs

      • Filters

      • Outputs

    The YAML configuration file does not support the following sections yet:

    • Parsers

    YAML configuration is used in the smoke tests for containers, so an always-correct up-to-date example is here: .

    Env

    The env section allows the definition of configuration variables that will be used later in the configuration file.

    Example:

    Includes

    The includes section allows the files to be merged into the YAML configuration to be identified as a list of filenames. If no path is provided, then the file is assumed to be in a folder relative to the file referencing it.

    Example:

    Service

    The service section defines the global properties of the service. The Service keys available as of this version are described in the following table:

    Key
    Description
    Default Value

    The following is an example of a service section:

    For scheduler and retry details, please check there:

    Pipeline

    A pipeline section will define a complete pipeline configuration, including inputs, filters and outputs subsections.

    Each of the subsections for inputs, filters and outputs constitutes an array of maps that has the parameters for each. Most properties are either simple strings or numbers so can be define directly, ie:

    This pipeline consists of two inputs; a tail plugin and an http server plugin. Each plugin has its own map in the array of inputs consisting of simple properties. To use more advanced properties that consist of multiple values the property itself can be defined using an array, ie: the record and allowlist_key properties for the record_modifier filter:

    In the cases where each value in a list requires two values they must be separated by a space, such as in the record property for the record_modifier filter.

    Input

    An input section defines a source (related to an input plugin). Here we will describe the base configuration for each input section. Note that each input plugin may add it own configuration keys:

    Key
    Description

    The Name is mandatory and it lets Fluent Bit know which input plugin should be loaded. The Tag is mandatory for all plugins except for the input forward plugin (as it provides dynamic tags).

    Example input

    The following is an example of an input section for the cpu plugin.

    Filter

    A filter section defines a filter (related to a filter plugin). Here we will describe the base configuration for each filter section. Note that each filter plugin may add its own configuration keys:

    Key
    Description

    The Name is mandatory and it lets Fluent Bit know which filter plugin should be loaded. The Match or Match_Regex is mandatory for all plugins. If both are specified, Match_Regex takes precedence.

    Example filter

    The following is an example of a filter section for the grep plugin:

    Output

    The outputs section specify a destination that certain records should follow after a Tag match. Currently, Fluent Bit can route up to 256 OUTPUT plugins. The configuration supports the following keys:

    Key
    Description

    Example output

    The following is an example of an output section:

    Example: collecting CPU metrics

    The following configuration file example demonstrates how to collect CPU metrics and flush the results every five seconds to the standard output:

    Processors

    In recent versions of Fluent-Bit, the input and output plugins can run in separate threads. In Fluent-Bit 2.1.2, we have implemented a new interface called "processor" to extend the processing capabilities in input and output plugins directly without routing the data. This interface allows users to apply data transformations and filtering to incoming data records before they are processed further in the pipeline.

    This functionality is only exposed in YAML configuration and not in classic configuration mode due to the restriction of nested levels of configuration.

    Example: Using processors.

    The following configuration file example demonstrates the use of processors to change the log record in the input plugin section by adding a new key "hostname" with the value "monox", and we use lua to append the tag to the log record. Also in the ouput plugin section we added a new key named "output" with the value "new data". All these without the need of routing the logs further in the pipeline.

    Sets the primary transport layer protocol used by the asynchronous DNS resolver, which can be overridden on a per plugin basis

    UDP

    log_file

    Absolute path for an optional log file. By default, all logs are redirected to the standard error interface (stderr).

    log_level

    Set the logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Values are accumulative, e.g., if 'debug' is set, it will include error, warning, info, and debug. Note that trace mode is only available if Fluent Bit was built with the WITH_TRACE option enabled.

    info

    parsers_file

    Path for a parsers configuration file. Only a single entry is currently supported.

    plugins_file

    Path for a plugins configuration file. A plugins configuration file allows the definition of paths for external plugins; for an example, .

    streams_file

    Path for the Stream Processor configuration file. To learn more about Stream Processing configuration go .

    http_server

    Enable built-in HTTP Server

    Off

    http_listen

    Set listening interface for HTTP Server when it's enabled

    0.0.0.0

    http_port

    Set TCP Port for the HTTP Server

    2020

    coro_stack_size

    Set the coroutines stack size in bytes. The value must be greater than the page size of the running system. Don't set too small a value (say 4096), or coroutine threads can overrun the stack buffer. Do not change the default value of this parameter unless you know what you are doing.

    24576

    scheduler.cap

    Set a maximum retry time in seconds. The property is supported from v1.8.7.

    2000

    scheduler.base

    Sets the base of exponential backoff. The property is supported from v1.8.7.

    5

    json.convert_nan_to_null

    If enabled, NaN is converted to null when fluent-bit converts msgpack to json.

    false

    sp.convert_from_str_to_num

    If enabled, Stream processor converts from number string to number type.

    true

    flush

    Set the flush time in seconds.nanoseconds. The engine loop uses a Flush timeout to define when is required to flush the records ingested by input plugins through the defined output plugins.

    5

    grace

    Set the grace time in seconds as an Integer value. The engine loop uses a Grace timeout to define the wait time on exit

    5

    daemon

    Boolean value to set if Fluent Bit should run as a Daemon (background) or not. Allowed values are: yes, no, on, and off. note: If you are using a Systemd based unit like the one we provide in our packages, do not turn on this option.

    Off

    Name

    Name of the input plugin. Defined as subsection of the inputs section.

    Tag

    Tag name associated to all records coming from this plugin.

    Log_Level

    Set the plugin's logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Defaults to the SERVICE section's Log_Level.

    Name

    Name of the filter plugin. Defined as a subsection of the filters section.

    Match

    A pattern to match against the tags of incoming records. It's case-sensitive and supports the star (*) character as a wildcard.

    Match_Regex

    A regular expression to match against the tags of incoming records. Use this option if you want to use the full regex syntax.

    Log_Level

    Set the plugin's logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. Defaults to the SERVICE section's Log_Level.

    Name

    Name of the output plugin. Defined as a subsection of the outputs section.

    Match

    A pattern to match against the tags of incoming records. It's case-sensitive and supports the star (*) character as a wildcard.

    Match_Regex

    A regular expression to match against the tags of incoming records. Use this option if you want to use the full regex syntax.

    Log_Level

    Set the plugin's logging verbosity level. Allowed values are: off, error, warn, info, debug and trace. The output log level defaults to the SERVICE section's Log_Level.

    https://github.com/fluent/fluent-bit/blob/master/packaging/testing/smoke/container/fluent-bit.yaml
    scheduling and retries
    Processor example

    dns.mode

    # setting up a local environment variable
    env:
        flush_interval: 1
    
    # service configuration
    service:
        flush:       ${flush_interval}
        log_level:   info
        http_server: on
    # defining file(s) to include into the current configuration. This includes illustrating using a relative path reference
    includes:
        - inclusion-1.yaml
        - subdir/inclusion-2.yaml
    
    service:
        flush: 5
        daemon: off
        log_level: debug
    pipeline:
        inputs:
            ...
        filters:
            ...
        outputs:
            ...
    pipeline:
        inputs:
            - name: tail
              tag: syslog
              path: /var/log/syslog
            - name: http
              tag: http_server
              port: 8080
    pipeline:
        inputs:
            - name: tail
              tag: syslog
              path: /var/log/syslog
        filters:
            - name: record_modifier
              match: syslog
              record:
                  - powered_by calyptia
            - name: record_modifier
              match: syslog
              allowlist_key:
                  - powered_by
                  - message
    pipeline:
        inputs:
            - name: cpu
              tag: my_cpu
    pipeline:
        filters:
            - name: grep
              match: '*'
              regex: log aa
    pipeline:
        outputs:
            - name: stdout
              match: 'my*cpu'
    service:
        flush: 5
        daemon: off
        log_level: debug
    
    pipeline:
        inputs:
            - name: cpu
              tag: my_cpu
        outputs:
            - name: stdout
              match: 'my*cpu'
      service:
        log_level: info
        http_server: on
        http_listen: 0.0.0.0
        http_port: 2021
      pipeline:
        inputs:
          - name: random
            tag: test-tag
            interval_sec: 1
            processors:
              logs:
                - name: modify
                  add: hostname monox
                - name: lua
                  call: append_tag
                  code: |
                      function append_tag(tag, timestamp, record)
                         new_record = record
                         new_record["tag"] = tag
                         return 1, timestamp, new_record
                      end
        outputs:
          - name: stdout
            match: '*'
            processors:
              logs:
                - name: lua
                  call: add_field
                  code: |
                      function add_field(tag, timestamp, record)
                         new_record = record
                         new_record["output"] = "new data"
                         return 1, timestamp, new_record
                      end
    see here
    here