I need a little help, I'm trying to write from a kafka topic to a postgres table only specific fields and it doesn't work, it writes nulls. I haven't figured out how to post jsons to kafka topic so I'm getting them from a folder for now. I also tried formatting the json as single line since I was getting a separate message for each line in postgres. Also I think that kafka messages will be formatted as single line when I figure out how to post json messages, right? Anyways, here's my config:
{
"header": {
"topicName": "TOPIC1",
"topicVer1": 1,
"sentUtc": "2020-01-27T14:07:10Z",
"status": "Test",
"msgType": "Update",
"code": ["status"]
},
"body": {
"location": {
"lat": 40.9999990,
"lon": 29.9999997
},
"status": {
"general": "OK",
},
"tasks": [{
"id": "task-0001",
"status": "Read"
}]
}
}
What am I doing wrong? Also I will need to add whole json as a field, I created a jsonb column in my table, how to do it?
If you have the entire JSON object as a single line in a file then the file filter will create a field called [message] that contains the entire JSON. You can use that to populate the jsonb column. You will need a json filter to parse the JSON. You will then be able to refer to [header][topicName] and [header][sentUtc].
I am trying to send the whole kafka message as last column(message), I have it as character varying in postgres, what am I doing wrong? Is it not identified with "message"? I'm getting no error but the result in postgress is NULL.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.