Configure a custom Fluent Bit log drain

Use Custom Fluent Bit when the built-in Axiom and New Relic destinations do not match your logging provider. Coolify runs the configuration as supplied, so you must define the input, filters, parsing, output, authentication, and destination behavior that your provider requires.

The short version

Provide a complete Fluent Bit 5.1 configuration that accepts the forward protocol on port 24224 and sends records to your destination. Coolify writes the configuration, starts coolify-log-drain, and connects opted-in resource containers to it.

Coolify does not validate Fluent Bit syntax

Coolify blocks some plugins and directives, but it does not check the Fluent Bit syntax. An invalid directive, unavailable plugin, or rejected credential can leave coolify-log-drain stopped or unable to deliver logs.


Before you start

Provider requirementsCollect the endpoint, authentication value, TLS requirements, and payload format.
Fluent Bit configurationDefine the input, filters, parsing, output, retry, and flush behavior your destination needs.
Validated serverConfirm the resource server can reach the destination and that no other log drain is enabled.

Read the Fluent Bit configuration documentation before writing the configuration.

Treat the configuration as sensitive when it contains credentials. Coolify does not provide a separate custom environment-variable field for provider secrets. For secrets that must be a file, such as a Google Cloud service account key, read Use credential and certificate files.


How Coolify runs the configuration

From saved configuration to forwarded records

Coolify manages the container and file mounts, while your configuration controls Fluent Bit itself.

1

Save the main configuration

2

Write the server files

3

Start Fluent Bit 5.1

4

Receive resource records

5

Send records to the destination

  • Coolify saves Fluent Bit configuration and the optional Parser configuration.
  • It writes the managed files under /data/coolify/log-drains on the resource server.
  • The coolify-log-drain container starts from cr.fluentbit.io/fluent/fluent-bit:5.1 with -c /fluent-bit.conf.
  • Opted-in resources send Docker log records to tcp://127.0.0.1:24224 through the Fluentd driver.
  • Your filters, parsers, and outputs transform and deliver those records.

Your main configuration must listen for the Fluent Bit forward protocol on port 24224.

By default, Coolify writes these files on the resource server:

FilePurpose
/data/coolify/log-drains/fluent-bit.confThe complete value from Fluent Bit configuration
/data/coolify/log-drains/parsers.confThe optional value from Parser configuration
/data/coolify/log-drains/docker-compose.ymlThe Coolify-managed Fluent Bit service
/data/coolify/log-drains/files/An empty directory for your own files. Coolify does not change the files in it

The container mounts the two configuration files at /fluent-bit.conf and /parsers.conf, and the files directory read-only at /files.

Coolify writes these files again from your settings each time it starts coolify-log-drain. Do not edit the files on the server, because Coolify replaces your changes. Change the configuration in Log Drains instead.


Fluent Bit version and automatic updates

Coolify runs custom drains with the same Fluent Bit image as the built-in destinations. The current image is cr.fluentbit.io/fluent/fluent-bit:5.1.

Running drains update automatically

When a Coolify upgrade changes the log drain image or files, the next server check starts coolify-log-drain again with the new image. You do not have to disable and enable the drain.

Coolify versions before Fluent Bit 5.1 used cr.fluentbit.io/fluent/fluent-bit:2.0. Fluent Bit 2.0 does not get security fixes. For example, the fixes for the Fluent Bit vulnerabilities in VU#761751 are only in Fluent Bit 4.2.0 and later. Most configurations work on 5.1 without changes. Before you upgrade Coolify, do these checks:

  1. If your configuration sends records to a Fluentd server with the forward output, add retain_metadata_in_forward_mode false to that output. From Fluent Bit 5.0.4, this option is true by default, and Fluentd rejects these records.
  2. If you changed the files in /data/coolify/log-drains on the server by hand, copy your changes into Fluent Bit configuration and Parser configuration. The automatic update replaces the files on the server.
  3. Read the Fluent Bit upgrade notes for the plugins that you use.

If Coolify blocks your configuration, the update does not start. The running coolify-log-drain container continues to run with the old image until you fix the configuration.

After the update, make sure that the drain runs:

docker inspect -f '{{.Config.Image}}' coolify-log-drain
docker logs --tail 100 coolify-log-drain

Write the main configuration

This skeleton shows the required input and an example HTTPS output. Replace the host, URI, authentication, and output options with values supported by your provider:

[SERVICE]
  Flush        5
  Daemon       off
  Log_Level    info
  Parsers_File parsers.conf

[INPUT]
  Name              forward
  Listen            0.0.0.0
  Port              24224
  Buffer_Chunk_Size 1M
  Buffer_Max_Size   6M

[OUTPUT]
  Name   http
  Match  *
  Host   logs.example.com
  Port   443
  URI    /ingest
  format json
  tls    On

The example is not a complete configuration for a specific provider. Add the provider's required header, token, payload, retry, and TLS options before enabling the drain.

Use only input, filter, parser, and output plugins included in the Fluent Bit 5.1 image used by Coolify.

Coolify does not accept these plugins and directives:

Not acceptedWhere
lua, wasm, exec, exec_wasi, and file pluginsFluent Bit configuration
@ directives other than @SET, such as @INCLUDE, and the plugins_file keyFluent Bit configuration
Sections other than [SERVICE], [INPUT], [FILTER], [OUTPUT], [PARSER], and [MULTILINE_PARSER]Fluent Bit configuration
@ directivesParser configuration
Sections other than [PARSER] and [MULTILINE_PARSER]Parser configuration

Use credential and certificate files

Some outputs read a secret or a certificate from a file. A configuration value is one line, so you cannot put a multi-line value, such as a PEM private key, in the configuration.

To use a file:

  1. Copy the file to /data/coolify/log-drains/files/ on the resource server. Coolify does not change or delete the files in this directory.
  2. In Fluent Bit configuration, use the path /files/<name>.
  3. Disable and enable the drain, or start it again, so that Fluent Bit reads the file.

For example, to send logs to Google Cloud Logging, create a service account with the Logs Writer role, download its JSON key, and copy it to /data/coolify/log-drains/files/gcp.json:

[OUTPUT]
  Name                       stackdriver
  Match                      *
  google_service_credentials /files/gcp.json
  export_to_project_id       your-project-id
  resource                   generic_node
  location                   global
  namespace                  coolify
  node_id                    your-server-name

Do not use service_account_secret for the private key. Fluent Bit cannot read a PEM key from one configuration line, and the drain stops with error creating RSA context.

Use the same directory for TLS files, for example tls.ca_file /files/ca.pem, tls.crt_file /files/client.pem, and tls.key_file /files/client.key.


Add parser definitions

Parser configuration is optional. It becomes parsers.conf, but adding a parser definition does not apply it automatically. The main configuration must reference the parser.

For example, add this parser definition to Parser configuration:

[PARSER]
  Name   app_json
  Format json

Then add a parser filter to Fluent Bit configuration:

[FILTER]
  Name         parser
  Match        *
  Key_Name     log
  Parser       app_json
  Reserve_Data On

This example parses JSON stored in the incoming log field and preserves the other record fields.


Configure Coolify

  1. Open Servers and select the server that runs the resources.
  2. Open Log Drains.
  3. In Custom Fluent Bit, keep Status set to Disabled.
  4. Paste the complete main configuration into Fluent Bit configuration.
  5. If needed, paste parser definitions into Parser configuration.
  6. Select Save changes in the custom section.
  7. Set Status to Enabled. Coolify writes the files and starts coolify-log-drain.

Enable a resource

Follow Enable log draining for a resource, then restart or redeploy the resource.

Your custom configuration receives the Docker log record as delivered by the local Fluentd driver.

Record enrichment

Custom drains receive the Docker record but do not inherit the filters and record modifiers from the built-in destinations.

Built-in Axiom and New Relic

  • Add coolify.server_name automatically
  • Rename COOLIFY_APP_NAME to coolify.app_name
  • Exclude messages that start with 127.0.0.1

Custom Fluent Bit

  • Uses the record delivered by the local Fluentd driver
  • Must add or rename identifying fields in your configuration
  • Applies only the filters you define

Verify delivery

  1. Cause the opted-in resource to write a recognizable message to stdout or stderr.
  2. Wait for the Flush interval in your configuration.
  3. Confirm the message appears in the external destination.
  4. Confirm the Fluent Bit container remains running:
docker ps --filter name=coolify-log-drain
docker logs --tail 100 coolify-log-drain

Run these commands in Coolify's server terminal or over SSH on the server that hosts the resource.


Update the configuration

The configuration fields are read-only while the drain is enabled.

  1. Set Status to Disabled to stop coolify-log-drain.
  2. Update the main or parser configuration.
  3. Select Save changes.
  4. Set Status to Enabled again.
  5. Generate a new resource log and verify the result externally.

Fix a failed custom drain

  • Confirm the main configuration has a forward input listening on port 24224.
  • Read docker logs --tail 100 coolify-log-drain for syntax, plugin, DNS, TLS, and authentication errors.
  • Confirm every parser referenced by the main configuration exists in Parser configuration.
  • Confirm the selected plugins and options are available in Fluent Bit 5.1.
  • If the drain stopped after a Coolify upgrade, read Fluent Bit version and automatic updates.
  • Confirm the resource's Log drain setting is enabled and that the resource was restarted afterward.
  • Confirm the resource server can reach the configured output host and port.

Continue with log drains

On this page