Versions | v1.0 (td-agent3)

Record Accessor Plugin Helper API

record_accessor helper provides the unified access for event record. record_accessor uses jsonpath like syntax for target field. With this helper, you can easy to access nested field in the plugin.

Here is the code example with record_accessor helper:

require 'fluent/plugin/filter'

module Fluent::Plugin
  class ExampleFilter < Filter
    Fluent::Plugin.register_filter('example', self)

    # 1. load record_accessor helper
    helpers :record_accessor

    def configure(conf)

      # 2. call `record_accessor_create` to create object
      @accessor = record_accessor_create('$')

    # omit super, shutdown and other plugin API

    def filter(tag, time, record)
      # 3. call `call` method to get value
      value = # With `$`, access to record["user"]["name"]
      # ...

Table of Contents


  • dot notation: $. started parameter. Chain fields by .

This is simple syntax. For example, $.event.level for record["event"]["level"], $.key1[0].key2 for record["key1"][0]["key2"]

  • bracket notation: $[ started parameter. Chain fields by []

Useful for special characters, ., and etc: $['dot.key'][0]['space key'] for record["dot.key"][0]["space key"]

If you set non $. or $[ started value, e.g. key log, it is same as record["log"]. So using record_accessor doesn’t break existing plugin behaviour.



This method returns accessor object for event record. param is a string and see “Syntax” section for supported syntax.


After create object, call #call method with record object. # access record field.

record_accessor used plugins

Last updated: 2019-03-23 23:29:44 +0000

Versions | v1.0 (td-agent3)

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.