Is there a way to change the format in the middle in Telegraf?

I want to make data_format of input as grok , but output as json .

I’m using inputs.tail , outputs.socket_writer My settings are:

[[inputs.tail]]
 data_format = "grok"
 grok_patterns = ['%{TIMESTAMP_ISO8601:logdate} %{GREEDYDATA:message}']

...

[[outputs.socket_writer]]
data_format = "json"

And I am getting the following error log.

2020/07/08 07:21:10 [WA120009] Error is unexpected end of JSON input
2020/07/08 07:21:10 [WA120010] syntax error at byte offset 4096
2020/07/08 07:21:10 [WA120009] Error is invalid character'c' looking for beginning of value
2020/07/08 07:21:10 [WA120009] Error is invalid character'l' looking for beginning of value
2020/07/08 07:21:10 [WA120009] Error is invalid character'\\' looking for beginning of value
2020/07/08 07:21:10 [WA120009] Error is invalid character'/' looking for beginning of value
2020/07/08 07:21:10 [WA120009] Error is invalid character'h' looking for beginning of value
2020/07/08 07:21:10 [WA120009] Error is invalid character'a' looking for beginning of value
2020/07/08 07:21:10 [WA120009] Error is invalid character'p' looking for beginning of value

I think what you want to do is add a [[processors.parser]], which you can tell to parse the message field as json. See https://github.com/influxdata/telegraf/tree/master/plugins/processors/parser