Convert HashMap to Json in Logstash

I am using Logstash in which the input is kafka topic. Through java code we are pushing the HashMap to the topic. According to my requirements, I can't convert the HashMap to json string on my java code side. The example of HashMap is

[event:[logLevel:INFO, description:This is the test description, className:ClassName, eventType:EVENT_TEST, message:[key1:value1, key2:value2, key3:value3, key4:value4], timestamp:Mon Feb 20 20:36:33 GMT 2017]]

I want to convert this HashMap to json string in filter block as shown below

{"event":{"message":{"key4":"value4","key3":"value3","key2":"value2","key1":"value1"},"timestamp":"Mon Feb 20 18:56:32 IST 2017","logLevel":"INFO","description":"This is the test description","className":"HomePageController","eventType":"EVENT_TEST"}}

I am new to Logstash and I am not able to find which input type to use in my logstash config input and what filter to use filter to use or do I need to write my own filter?

You'd have to write something on your own. The correct solution is of course to change the source application to emit something sensible.

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