I'm trying to configure a logstash filter to add a field that contains one of more objects. In other words, I want the document json for the field to end up looking something like this:
I have that working by having one filter add a field with the value set to a json string that's defined directly in the config, coupled with an instance of the json filter to expand that back into a data structure:
It seems like there must be a better way of doing this; I don't like manually doing json encoding like this. The url value will be pulled out of the event data in the real config, so it would be susceptible to breaking, for one thing. Can anyone straighten me out?
By simplifying my config down, I must have ironically made things less clear. I was trying to avoid transforming anything at all; I'm adding a new field that I want to contain an object. In any event, this morning I finally searched for the right terms and came across a post here that got me to an acceptable solution.
It's not quite what I started out toward, but it's good enough. I'm not sure arrays of nested objects are a good idea anyway, even if possible. For posterity, to end up with a field called links that is an object/hash of label => url (what the keys and values represent in this example), this works:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.