Repository is archived
No commit activity in last 3 years
No release in over 3 years
Filter Plugin to create a new record containing the values converted by Ruby script.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 3.0.0
>= 3.1.0

Runtime

>= 0.12
 Project Readme

fluent-plugin-filter-record-map

Filter Plugin to create a new record containing the values converted by Ruby script.

Gem Version Build Status

Installation

Add this line to your application's Gemfile:

gem 'fluent-plugin-filter-record-map'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fluent-plugin-filter-record-map

Configuration

<filter>
  type record_map
  # map1: required
  map1 new_record["new_foo"] = record["foo"]
  map2 new_record["new_bar"] = record["bar"]
</filter>

Usage

Example1

<filter>
  type record_map
  map1 new_record["new_foo"] = record["foo"].upcase
  map2 new_record["new_bar"] = record["bar"].upcase
</filter>
$ echo '{"foo":"bar", "bar":"zoo"})' | fluentd test.data
#=> 2015-01-01 23:34:45 +0900 test.data: {"new_foo":"BAR","new_bar":"ZOO"}

Example2

<filter>
  type record_map
  map1 record.each {|k, v| new_record[k] = k + "." + v }
</filter>
$ echo '{"foo":"bar", "bar":"zoo"}' | fluent-cat test.data
#=> 2015-01-01 23:34:45 +0900 test.data: {"foo":"foo.bar","bar":"bar.zoo"}

Example3

<filter>
  type record_map
  map1 new_record = {"new_foo" => record["foo"]}
</filter>
$ echo '{"foo":"bar", "bar":"zoo"}' | fluent-cat test.data
#=> 2015-01-01 23:34:45 +0900 test.data: {"new_foo":"bar"}

Use tag, tag_parts

<filter>
  type record_map
  map1 new_record["tag"] = tag
  map2 new_record["new_foo"] = tag_parts[1] + "." + record["foo"]
</filter>
$ echo '{"foo":"bar", "bar":"zoo"}' | fluent-cat test.data
#=> 2015-01-01 23:34:45 +0900 test.data: {"tag":"test.data","new_foo":"data.foo"}

Use hostname

<filter>
  type record_map
  map1 new_record["hostname"] = hostname
</filter>

Use time

<filter>
  type record_map
  map1 new_record["time"] = time.strftime("%Y-%m-%d")
</filter>
$ echo '{"foo":"bar", "bar":"zoo"}' | fluent-cat test.data
#=> 2015-01-01 23:34:45 +0900 test.data: {"hostname":"my-host"}