Versions | v0.14 (td-agent3) | v0.12 (td-agent2) | v0.10 (td-agent1)

This page is for v0.14, not the latest stable version which is v0.12. For the latest stable version of this article, click here.


Formatter Overview

Fluentd has 7 types of plugins: Input, Parser, Filter, Output, Formatter, Storage and Buffer. This article gives an overview of Formatter Plugin.

Table of Contents

Overview

Sometimes, the output format for an output plugin does not meet one’s needs. Fluentd has a pluggable system called Formatter that lets the user extend and re-use custom output formats.

How To Use

For an output plugin that supports Formatter, the <format> directive can be used to change the output format.

For example, by default, out_file plugin outputs data as

2014-08-25 00:00:00 +0000<TAB>foo.bar<TAB>{"k1":"v1", "k2":"v2"}

However, if you set @type json in <format> like this

<match foo.bar>
  @type file
  path /path/to/file
  <format>
    @type json
  </format>
</match>

The output changes to

{"time": "2014-08-25 00:00:00 +0000", "tag":"foo.bar", "k1:"v1", "k2":"v2"}

i.e., each line is a single JSON object with “time” and “tag fields to retain the event’s timestamp and tag.

See this section to learn how to develop a custom formatter.

List of Built-in Formatters

List of Output/Filter Plugins with Formatter Support

Last updated: 2016-06-13 06:11:23 UTC

Versions | v0.14 (td-agent3) | v0.12 (td-agent2) | v0.10 (td-agent1)

If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is a open source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.

Interested in the Fluentd Newsletters?