I have another issue - one of the json fields is named message and also logstash by default gives message field. I want to rename josn field "message" to something like "json_message". If I use mutate filter, I think it would replace both the fields. Is there any way where I can rename fields only for json fields?
If you have a field called "message" and you parse the JSON, by default it will overwrite the original "message". If you set target on the JSON filter than you will have the "message" of the JSON inside someField, and then you can rename that using something like
My Json object may have several fields depending on the event. It may have a least of 3 fields or it may even have up to 20 fields. If I use a target field named jsondoc, all the fields will be inside jsondoc. But I want all the fields to be independent instead in jsondoc. Is there a way?
Yes, do not set a target, and the fields will be at the root level. In that case, if the JSON includes a field called message it will overwrite the message field. If you really want to retain the message field then mutate+rename message to saved_message, parse saved_message with a json filter, mutate+rename message to json_message, mutate+rename saved_message back to message..
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.