Join our community of software engineering leaders and aspirational developers. Always
stay in-the-know by getting the most important news and exclusive content delivered
fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter
in the past. Click the button below to open the re-subscribe form
in a new tab. When you're done, simply close that tab and continue
with this form to complete your subscription.
The New Stack does not sell your information or share it with
unaffiliated third parties. By continuing, you agree to our
Terms of Use and
Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!
We’re so glad you’re here. You can expect all the best TNS content to arrive
Monday through Friday to keep you on top of the news and at the top of your game.
What’s next?
Check your inbox for a confirmation email where you can adjust your preferences
and even join additional groups.
Follow TNS on your favorite social media networks.
Fluent Bit is a widely used open source data collection agent, processor and forwarder that enables you to collect logs, metrics and traces from various sources, filter and transform them, and then forward them to multiple destinations.
Fluent Bit version 2 introduced the concept of processors, which, like filters, enrich or transform telemetry data.
With the release of Fluent Bit version 4, a new feature was introduced: conditional log processing using processors. In this post, we will explore how to use Fluent Bit processors to modify logs based on their content conditionally.
Prerequisites
Docker: Installed on your system.
Familiarity with Fluent Bit concepts: Such as inputs, outputs, parsers and filters. If you’re unfamiliar with these concepts, please refer to the official documentation.
What Are Processors?
Processors are components that modify, transform or enhance data as it flows through Fluent Bit. Unlike filters, processors are tightly coupled to inputs, which means they execute immediately and avoid creating a performance bottleneck.
How Are Processors Different From Filters?
While both processors and filters can manipulate data, there are key differences:
Performance impact: Processors avoid creating bottlenecks since they don’t require buffering between stages.
Configuration: Processors are only available in YAML configuration format.
Scope: Filters can be implemented to mimic processors, but not vice versa.
Conditional Log Processing Using Processors
Conditional processing enables you to selectively apply processors to logs based on the values of fields within those logs. This allows you to create processing pipelines that only process records that meet specific criteria, ignoring the rest.
You can turn a standard processor into a conditional processor by adding a `condition` block to the processor’s YAML configuration settings. These `condition` blocks use the following syntax:
The comparison operator to evaluate whether the rule is true. This parameter (`condition.rules.op`) is distinct from the `condition.op` parameter and has different possible values.
Rules are evaluated against each log that passes through your data pipeline.
Our Use Case
For our demonstration, we’ll implement a common scenario:
Objective: Automatically tag error-level logs with `priority=high` to enable special handling downstream.
This is valuable for:
Triggering immediate alerts for critical errors.
Routing high-priority logs to dedicated analysis systems.
Ensuring error logs are retained longer than routine logs.
Instructions
1. Create the Fluent Bit Directory
mkdir fluent-bit-conditional-demo
cd fluent-bit-conditional-demo
2. Create the Input Log File
Create the input.log file with the following content:
In the above configuration, we set a pipeline that reads log entries from a file, parses them as JSON and prints them on standard output (STDOUT).
In the input section, the `tail` plugin reads the logs from the `/test/input.log` file and adds a `log.test` tag to every record. The `content_modifier` processor then inspects each parsed record and, if the log level matches `error`, adds a new priority field. Finally, all processed logs are routed to the standard output.
Chronosphere, a Palo Alto Networks company, is the observability platform built for control in the modern, containerized world. Recognized as a leader by major analyst firms, Chronosphere empowers customers to focus on the data and insights that matter to reduce data complexity, optimize costs, and remediate issues faster. Visit chronosphere.io.