# Logstash filter to extract string from Json in postgresql table

**URL:** <https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252>\
**Category:** Logstash\
**Created:** [July 23, 2018, 8:44pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252 "2018-07-23T20:44:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harman\_Gurm](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Harman\_Gurm](https://discuss.elastic.co/u/Harman_Gurm)\
**Post date:** [July 23, 2018, 8:44pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/1 "2018-07-23T20:44:35Z")

</div>

Hi,

I am using jdbc plugin to get data out of postgresql, but one of my column is having many values as below with 100 unique field names.

I am looking to extract string from json format by logstash filter.

```
 id | columns | timestamp | query_id | task_id
-------+----------------------------------------------+----------------------------+----------------------+---------------------------
     1 | {"uid": "112", "name": "redis-server"} | 2018-07-18 18:45:39.045387 | 1 | 2
     2 | {"uid": "0", "name": "celery"} | 2018-07-18 18:45:39.047671 | 1 |        

```

input:

{"uid": "112", "name": "redis-server"}

output to be like:

uid: 112  
name: redis-server

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 24, 2018, 12:18am UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/2 "2018-07-24T00:18:39Z")

</div>

A [json](https://www.elastic.co/guide/en/logstash/current/plugins-filters-json.html) filter should handle this.

---

<div class="post-metadata">

**Author:** ![Harman\_Gurm](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Harman\_Gurm](https://discuss.elastic.co/u/Harman_Gurm)\
**Post date:** [July 24, 2018, 2:43pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/3 "2018-07-24T14:43:48Z")

</div>

Hi @Badger , i tried below is not working:

filter {  
json{source =\> "columns"  
}  
}

I am getting [WARN][logstash.inputs.jdbc] Exception when executing JDBC query {:exception=\>#\<Sequel::DatabaseError: Java::OrgLogstash::MissingConverterException: Missing Converter handling for full class name=org.postgresql.util.PGobject, simple name=PGobject\>}

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 24, 2018, 2:58pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/4 "2018-07-24T14:58:08Z")

</div>

That's a problem with the input. You don't even have an event at that point. I would ask a new question about Java::OrgLogstash::MissingConverterException

---

<div class="post-metadata">

**Author:** ![Harman\_Gurm](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Harman\_Gurm](https://discuss.elastic.co/u/Harman_Gurm)\
**Post date:** [July 24, 2018, 3:11pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/5 "2018-07-24T15:11:25Z")

</div>

Hi @Badger I have this issue when i try to import "columns" in above table, if i exclude "columns"(containing json i dont have any error message), i am able to pull data

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 24, 2018, 4:19pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/6 "2018-07-24T16:19:12Z")

</div>

> [@Badger](#):
>
> I would ask a new question about Java::OrgLogstash::MissingConverterException

As I said, I would ask a new question about Java::OrgLogstash::MissingConverterException. You need to get the input working before you worry about the filter.

A PGobject is used to represent an unknown type, so the input does not know what to do with it. It's probably related to the fact that the column contains JSON. Perhaps you need to CAST the column (because you want a string to input to the json filter). I don't know. I don't use the jdbc input.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 21, 2018, 4:19pm UTC](https://discuss.elastic.co/t/logstash-filter-to-extract-string-from-json-in-postgresql-table/141252/7 "2018-08-21T16:19:14Z")

</div>

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