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.
Before you start
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
By default, Coolify writes these files on the resource server:
| File | Purpose |
|---|---|
/data/coolify/log-drains/fluent-bit.conf | The complete value from Fluent Bit configuration |
/data/coolify/log-drains/parsers.conf | The optional value from Parser configuration |
/data/coolify/log-drains/docker-compose.yml | The 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.
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:
- If your configuration sends records to a Fluentd server with the
forwardoutput, addretain_metadata_in_forward_mode falseto that output. From Fluent Bit 5.0.4, this option istrueby default, and Fluentd rejects these records. - If you changed the files in
/data/coolify/log-drainson the server by hand, copy your changes into Fluent Bit configuration and Parser configuration. The automatic update replaces the files on the server. - 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-drainWrite 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 OnThe 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 accepted | Where |
|---|---|
lua, wasm, exec, exec_wasi, and file plugins | Fluent Bit configuration |
@ directives other than @SET, such as @INCLUDE, and the plugins_file key | Fluent Bit configuration |
Sections other than [SERVICE], [INPUT], [FILTER], [OUTPUT], [PARSER], and [MULTILINE_PARSER] | Fluent Bit configuration |
@ directives | Parser 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:
- Copy the file to
/data/coolify/log-drains/files/on the resource server. Coolify does not change or delete the files in this directory. - In Fluent Bit configuration, use the path
/files/<name>. - 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-nameDo 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 jsonThen add a parser filter to Fluent Bit configuration:
[FILTER]
Name parser
Match *
Key_Name log
Parser app_json
Reserve_Data OnThis example parses JSON stored in the incoming log field and preserves the other record fields.
Configure Coolify
- Open Servers and select the server that runs the resources.
- Open Log Drains.
- In Custom Fluent Bit, keep Status set to Disabled.
- Paste the complete main configuration into Fluent Bit configuration.
- If needed, paste parser definitions into Parser configuration.
- Select Save changes in the custom section.
- 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.
Verify delivery
- Cause the opted-in resource to write a recognizable message to
stdoutorstderr. - Wait for the Flush interval in your configuration.
- Confirm the message appears in the external destination.
- Confirm the Fluent Bit container remains running:
docker ps --filter name=coolify-log-drain
docker logs --tail 100 coolify-log-drainRun 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.
- Set Status to Disabled to stop
coolify-log-drain. - Update the main or parser configuration.
- Select Save changes.
- Set Status to Enabled again.
- Generate a new resource log and verify the result externally.
Fix a failed custom drain
- Confirm the main configuration has a
forwardinput listening on port24224. - Read
docker logs --tail 100 coolify-log-drainfor 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.
