# How to Modify input JSON ie. message and send output to ES

**URL:** <https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902>\
**Category:** Logstash\
**Created:** [April 13, 2018, 5:20am UTC](https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902 "2018-04-13T05:20:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)\
**Post date:** [April 13, 2018, 5:20am UTC](https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902/1 "2018-04-13T05:20:39Z")

</div>

message is

{'hostName': 'ramesh-nagargoje-dt1', 'bseid': 1234, 'branch': u'rel-29', 'boardName': u'darcy', 'os': u'android' 'logs': '[2341282.674723] usb 1-8: USB disconnect, device number 57\n[2341288.676677] usb 1-7: new high-speed USB device number 60 using xhci\_hcd\n[2341288.695194] usb 1-7: New USB device found, idVendor=0955, idProduct=b437\n[2341288.695200] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3\n[2341288.695204]  
}

expected output is:  
{  
'hostName': 'ramesh-nagargoje-dt1',  
'bseid': 1234,  
'branch': u'rel-29',  
'boardName': u'darcy',  
'os': u'android',  
'logs': '[2341282.674723] usb 1-8: USB disconnect, device number 57\n[2341288.676677] usb 1-7: new high-speed USB device number 60 using xhci\_hcd\n[2341288.695194] usb 1-7: New USB device found, idVendor=0955, idProduct=b437\n[2341288.695200] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3\n[2341288.695204]  
}

---

<div class="post-metadata">

**Author:** ![Suman\_Reddy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suman_reddy1/32/27303_2.png) [@Suman\_Reddy1](https://discuss.elastic.co/u/Suman_Reddy1)\
**Post date:** [April 13, 2018, 6:01am UTC](https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902/2 "2018-04-13T06:01:28Z")

</div>

Could you be more specific please?  
Both the messages are same, except that the initial one dont have any new line chars. Thats the difference I could see.

Please create an output part in your logstash config and point that to your ES instance.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 13, 2018, 6:15am UTC](https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902/3 "2018-04-13T06:15:52Z")

</div>

> {'hostName': 'ramesh-nagargoje-dt1', 'bseid': 1234, 'branch': u'rel-29', 'boardName': u'darcy', 'os': u'android' 'logs': '[2341282.674723] usb 1-8: USB disconnect, device number 57\n[2341288.676677] usb 1-7: new high-speed USB device number 60 using xhci\_hcd\n[2341288.695194] usb 1-7: New USB device found, idVendor=0955, idProduct=b437\n[2341288.695200] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3\n[2341288.695204]  
> }

This isn't JSON at all; it's the string representation a Python data structure.

---

<div class="post-metadata">

**Author:** ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)\
**Post date:** [April 15, 2018, 1:37pm UTC](https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902/4 "2018-04-15T13:37:21Z")

</div>

thank for your reply @magnusbaeck and @Suman_Reddy1 I got the solution. It was problem of python code while sending input to the kafka consumer i forgot to send json object my mistake i have sent as string.

following lines Solve my problem.

KafkaProducer(bootstrap\_servers='10.24.134.161:9092',value\_serializer=lambda v: json.dumps(v).encode('utf-8'))  
producer.send('fast-messages',key=str(socket.gethostname()),value = jsonDemo )

---

<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:** [May 13, 2018, 1:37pm UTC](https://discuss.elastic.co/t/how-to-modify-input-json-ie-message-and-send-output-to-es/127902/5 "2018-05-13T13:37:41Z")

</div>

Closed on May 13, 2018, 1:37pm UTC

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