# Configuration File

There are some cases where using the command line to start Fluent Bit is not ideal. When running Fluent Bit as a service, a configuration file is preferred.

Fluent Bit allows to use one configuration file which works at a global scope and uses the [schema](https://github.com/fluent/fluent-bit-docs/tree/ad9d80e5490bd5d79c86955c5689db1cb4cf89db/configuration/configuration_schema.md) defined previously.

The configuration file supports four types of sections:

* [Service](#config_section)
* [Input](#config_input)
* [Filter](#config_filter)
* [Output](#config_output)

In addition there is an additional feature to include external files:

* [Include File](#config_include_file)

## Service <a href="#config_section" id="config_section"></a>

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 |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| Flush             | Set the flush time in seconds. Everytime it timeouts, the engine will flush the records to the output plugin.                                                                                                                                                                      | 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.                                                                                                                                                            | Off           |
| Log\_File         | Absolute path for an optional log file.                                                                                                                                                                                                                                            |               |
| Log\_Level        | Set the logging verbosity level. Allowed values are: error, info, debug and trace. Values are accumulative, e.g: if 'debug' is set, it will include error, 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 used.                                                                                                                                                                                               |               |
| Plugins\_File     | Path for a *plugins* configuration file. A *plugins* configuration file allows to define paths for external plugins, for an example [see here](https://github.com/fluent/fluent-bit/blob/master/conf/plugins.conf).                                                                |               |
| Streams\_File     | Path for the Stream Processor configuration file. For details about the format of SP configuration file [see here](https://github.com/fluent/fluent-bit-docs/tree/5ce8601b848ea2a6ca53af126d7f7dd69e864a9e/configuration/stream_processor.md).                                     |               |
| 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.                                                                                                                                                                        | 24576         |

### Example

The following is an example of a *SERVICE* section:

```python
[SERVICE]
    Flush           5
    Daemon          off
    Log_Level       debug
```

## Input <a href="#config_input" id="config_input"></a>

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                                                  |
| ---- | ------------------------------------------------------------ |
| Name | Name of the input plugin.                                    |
| Tag  | Tag name associated to all records comming from this plugin. |

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:

```python
[INPUT]
    Name cpu
    Tag  my_cpu
```

## Filter <a href="#config_filter" id="config_filter"></a>

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                                                                                                            |   |
| ------------ | ---------------------------------------------------------------------------------------------------------------------- | - |
| Name         | Name of the filter plugin.                                                                                             |   |
| Match        | It sets a pattern to match certain records Tag. It's case sensitive and support the star (\*) character as a wildcard. |   |
| Match\_Regex | It sets a pattern to match certain records Tag.                                                                        |   |

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:

```python
[FILTER]
    Name  stdout
    Match *
```

## Output <a href="#config_output" id="config_output"></a>

The *OUTPUT* section specify a destination that certain records should follow after a Tag match. The configuration support the following keys:

| Key          | Description                                                                                                            |
| ------------ | ---------------------------------------------------------------------------------------------------------------------- |
| Name         | Name of the output plugin.                                                                                             |
| Match        | It sets a pattern to match certain records Tag. It's case sensitive and support the star (\*) character as a wildcard. |
| Match\_Regex | It sets a pattern to match certain records Tag.                                                                        |

### Example

The following is an example of an *OUTPUT* section:

```python
[OUTPUT]
    Name  stdout
    Match my*cpu
```

### 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:

```python
[SERVICE]
    Flush     5
    Daemon    off
    Log_Level debug

[INPUT]
    Name  cpu
    Tag   my_cpu

[OUTPUT]
    Name  stdout
    Match my*cpu
```

## Include File <a href="#config_include_file" id="config_include_file"></a>

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:

```
@INCLUDE somefile.conf
```

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:

```
@INCLUDE input_*.conf
```
