tcp socket does not send message after write immediately
I have tcp client configured in my code and sending stats to telegraf. But the telegraf service on tcp recieved messages after connection close. And they are batching the data till then and giving error in json parsing eg:
Malformed packet: [{"hostName":"172.16.0.145","id":"redshift","test":100}{"hostName":"172.16.0.145","id":"redshift","test":100}{"hostName":"172.16.0.145","id":"redshift","test":100}{"hostName":"172.16.0.145","id":"redshift","test":100}], Error: unable to parse out as JSON, invalid character '{' after top-level value
Your tcp client should be breaking up multiple packets on newlines, I don't think this is telegraf's problem.
Actually we are not splitting newlines on JSON input. I don't think we can split newlines, since JSON allows for newlines within the same object. ie, if we split on newlines then users sending this:
{
"a": 5,
"b": {
"c": 6
},
"mytag": "foobar",
"othertag": "baz"
}
would get failures.
Telegraf is not doing the aggregating. You need to have your tcp client send separate packets for each json object.