Logstash JDBC - how to handle json field?

I have postgresql that stores some data as json fields, for example:

{"adults":2,"children":{"total":0,"ages":[]}} 

I use the logstash-input-jdbc plugin to process data.
How to parse json from jdbc? From the logs, I see that the fields come as PGObject:

"travelers_json" => #<Java::OrgPostgresqlUtil::PGobject:0x278826b2>

which has properties valueand type.

I tried using the json filter, but I don’t know how to access the property valueto submit to the json filter? What I tried:

 source => "[travelers_json][value]"
 source => "travelers_json.value"
 source => "%{travelers_json.value}"

Do I need to miss something very obvious here?

+4
source share
1 answer

So the easiest way was to convert json to text in postgresql:

SELECT travelers_json::TEXT from xxx

but I still would like to know how to access this PGobject

+1

Source: https://habr.com/ru/post/1626634/


All Articles