# How to parse flatten json logs in logstash?

**URL:** <https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802>\
**Category:** Logstash\
**Created:** [May 3, 2022, 6:31am UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802 "2022-05-03T06:31:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![talbehat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talbehat/32/84367_2.png) [@talbehat](https://discuss.elastic.co/u/talbehat)\
**Post date:** [May 3, 2022, 6:31am UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802/1 "2022-05-03T06:31:40Z")

</div>

Getting error :-

[2022-05-03T22:21:09,874][INFO][logstash.filters.flattenjson][main] Running flatten\_json filter {:event=\>#LogStash::Event:0x246b5df6}

[2022-05-03T22:21:09,880][ERROR][org.logstash.execution.WorkerLoop][main] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash.  
org.jruby.exceptions.NoMethodError: (NoMethodError) undefined method `keys' for #String:0x6c1a80ac  
at RUBY.flatten(/vendor/local\_gems/978a9a1d/logstash-filter-flatten\_json-0.1.0/lib/logstash/filters/flatten\_json.rb:68) ~[?:?]

please any idea for this

---

<div class="post-metadata">

**Author:** ![ibra\_013](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibra_013/32/104827_2.png) [@ibra\_013](https://discuss.elastic.co/u/ibra_013)\
**Post date:** [May 3, 2022, 4:53pm UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802/2 "2022-05-03T16:53:35Z")

</div>

Hi,

cloud you share your logstash config.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 3, 2022, 4:58pm UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802/3 "2022-05-03T16:58:58Z")

</div>

Assuming that the filter is some variant of [this](https://github.com/mavlyutov/logstash-filter-flatten_json/blob/master/lib/logstash/filters/flatten_json.rb#L65), it expects the source to be a hash, and you have passed it text.

---

<div class="post-metadata">

**Author:** ![talbehat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talbehat/32/84367_2.png) [@talbehat](https://discuss.elastic.co/u/talbehat)\
**Post date:** [May 4, 2022, 5:33am UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802/4 "2022-05-04T05:33:01Z")

</div>

Hi [ibra\_013](https://discuss.elastic.co/u/ibra_013)

i am using filter [this](https://github.com/mavlyutov/logstash-filter-flatten_json/blob/master/lib/logstash/filters/flatten_json.rb#L65).

Hi [Badger](https://discuss.elastic.co/u/Badger)

i am reading flatten json file as same as other logs file, [logstash-flatten-json-filter](https://github.com/mavlyutov/logstash-filter-flatten_json/blob/master/lib/logstash/filters/flatten_json.rb#L65) is this plugin fine to support flatten json or need to use another plugin?

Thank you

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 4, 2022, 2:57pm UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802/5 "2022-05-04T14:57:19Z")

</div>

It is a third party filter, which is OK. But you need to pass it a field which is a hash, not a string.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2022, 2:57pm UTC](https://discuss.elastic.co/t/how-to-parse-flatten-json-logs-in-logstash/303802/6 "2022-06-01T14:57:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
