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

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]
}

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.

{'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.

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 )

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