Modify fluentd json output
Asked Answered
C

1

13

How can we easily transform with fluentd( and plugins ) something like this

{
    "remote": "87.85.14.126",
    "city": "saint-hubert"
}

To this:

{
   "geoip": {
       "remote": "87.85.14.126",
       "city": "saint-hubert"
   }
}

Thank you

Calla answered 17/12, 2014 at 10:55 Comment(4)
A Fluentd maintainer here. Right now, this is kind of hard to do. But I am trying to work with upstream to make it possible in record_transformer (docs.fluentd.org/articles/filter_record_transformer). Stay tuned.Punkah
Thanks. However, your link seems to be down at this timeCalla
Oops. that was meant to be docs.fluentd.org/v0.12/articles/filter_record_transformerPunkah
@KiyotoTamura Does fluentd support this now?Symposiarch
S
7

Based on the answer by repeatedly(https://github.com/repeatedly).

<filter test.**>
  @type record_transformer
  enable_ruby true
  auto_typecast true

  <record>
    geoip ${{"remote" => "${remote}", "city" => "${city}"}}
  </record>
</filter>
Symposiarch answered 20/8, 2016 at 2:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.