Simple Stream Processing with Fluentd
Last updated
Was this helpful?
Last updated
Was this helpful?
Sometimes, you need to transform the data stream in a certain way. For example, you might want to extract a portion of data for error reporting, or need to append additional information to events for later inspection.
This article explains the common data manipulation techniques in detail.
is a built-in plugin that allows to filter the data stream using regular expressions.
Suppose you are managing a web service, and try to monitor the access logs using Fluentd. In this case, an event in the data stream will look like:
Let's filter out all the successful responses with 2xx status codes so that we can easily inspect if any error has occurred in the service:
You can also filter the data using multiple fields. The following configuration will keep all 5xx server errors, except those coming from the test directory:
Suppose you are running a web service on multiple web servers, and you want to record which server handled each request. This can be implemented trivially using this plugin:
This will produce an event like this:
is a built-in plugin that enables it to inject arbitrary data into events.
Note that ${hostname}
is a predefined variable supplied by the plugin. You can also define a custom variable, or even evaluate arbitrary ruby expressions. For more details, see .
If this article is incorrect or outdated, or omits critical information, please . is an open-source project under . All components are available under the Apache 2 License.