Search code examples
jsonfluentd

Fluentd modify json output


I need to modify output to from this

"payload": {
  "a": "value",
  "b": "value",
  .....
}

to

"a": "value",
"b": "value",
.....

I was looking at record_transformer but it looks like this is only to for example add new field or modify value of existing json property. Is it possible to extract data like i want to?


Solution

  • You can try something like this [If key names are fixed]

    @type record_transformer
    <record>
       a $${record["payload"]["a"]
       remove_keys payload
    </record>
    

    Or this plugin for dynamic keys https://github.com/kazegusuri/fluent-plugin-flatten-hash