Issues parsing JSON with deep nesting

One step closer to the edge. So I got the split { field => "[data][children]" } working and the data is coming in from that. But getting an error for the replies split to get the data in from those.

[2019-04-11T15:04:00,651][WARN ][logstash.filters.split ] Only String and Array types are splittable. field:[replies] is of type = NilClass

split { field => "[data][children]" }

if [data][children][data][body]
  {
  mutate
    {
      add_field => {
        "id" => "%{[data][children][data][id]}"
        "replyid" => "%{[data][children][data][id]}"
        "reference" => "%{[data][children][data][subreddit]}"
        "text" => "%{[data][children][data][body]}"
        "postid" => "%{[data][children][data][link_id]}"
        "author" => "%{[data][children][data][author]}"
        "score" => "%{[data][children][data][score]}"
        "link" => "http://reddit.com%{[data][children][data][permalink]}"
      }
    }
  }
mutate
  {
    remove_field => ["[data]"]
  }

split { field => "[replies]" }

if [replies][body]
  {
  mutate
    {
      add_field => {
        "id" => "%{[replies][id]}"
        "replyid" => "%{[replies][id]}"
        "reference" => "%{[replies][subreddit]}"
        "text" => "%{[replies][body]}"
        "postid" => "%{[replies][link_id]}"
        "author" => "%{[replies][author]}"
        "score" => "%{[replies][score]}"
        "link" => "http://reddit.com%{[replies][permalink]}"
      }
    }
  }
  mutate
  {
    remove_field => ["[replies]"]
  }

That's on the first event, which doesn't have any replies. I thought you were going to drop that... Otherwise

if [replies] { split { field => "[replies]" } }

[data][children][data] has the initial comment which is needed and the code you created has all the replies to those comments.
Basically I need to have the [id],[subreddit],[body],[link_id],[author],[score], and [permalink] of each.

So currently I am trying to bring the [replies] and the [data][children][data] into the root.

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