# One row from postgres table inserted into elasticsearch

**URL:** <https://discuss.elastic.co/t/one-row-from-postgres-table-inserted-into-elasticsearch/170883>\
**Category:** Logstash\
**Created:** [March 5, 2019, 11:40am UTC](https://discuss.elastic.co/t/one-row-from-postgres-table-inserted-into-elasticsearch/170883 "2019-03-05T11:40:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhari](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@rhari](https://discuss.elastic.co/u/rhari)\
**Post date:** [March 5, 2019, 11:40am UTC](https://discuss.elastic.co/t/one-row-from-postgres-table-inserted-into-elasticsearch/170883/1 "2019-03-05T11:40:13Z")

</div>

New to Logstash, ElasticSearch etc.

Created new LogStash configuration for pulling records from Postgres DB and push to elasticsearch, however seeing only only row is pushed to elasticsearch,

input {  
jdbc {  
# Postgres jdbc connection string to our database, nnm  
jdbc\_connection\_string =\> "jdbc:postgresql://localhost:5432/nnm"  
# The user we wish to execute our statement as  
jdbc\_user =\> "postgres"  
jdbc\_password =\> "nnmP0stgr3S"  
jdbc\_validate\_connection =\> true  
# The path to our downloaded jdbc driver  
jdbc\_driver\_library =\> "/opt/OV/nmsas/server/nms/lib/postgresql.jar"  
# The name of the driver class for Postgresql  
jdbc\_driver\_class =\> "org.postgresql.Driver"  
schedule =\> "30 \* \* \* \* \*"  
# our query  
statement =\> "select NMS\_NODE.name,nms\_node\_stat.cur\_stat from nms\_node,nms\_node\_stat where nms\_node.id = nms\_node\_stat.id;"  
}  
}  
output {  
elasticsearch {  
hosts =\> "localhost:9200"  
index =\> "nms\_node"  
document\_type =\> "nms\_node"  
document\_id =\> "%{nms\_node.id}"  
}  
stdout { codec =\> rubydebug { metadata =\> true } }  
}

Please help.

---

<div class="post-metadata">

**Author:** ![rhari](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@rhari](https://discuss.elastic.co/u/rhari)\
**Post date:** [March 6, 2019, 5:30am UTC](https://discuss.elastic.co/t/one-row-from-postgres-table-inserted-into-elasticsearch/170883/2 "2019-03-06T05:30:34Z")

</div>

I suspect sql query is wrong or document\_id is wrong.

When I run the query "select name,id from nms\_node" it is giving me count of records from nms\_table.

Anyone has encountered this issue, please correct me if I am wrong.

---

<div class="post-metadata">

**Author:** ![hermann102](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hermann102/32/41615_2.png) [@hermann102](https://discuss.elastic.co/u/hermann102)\
**Post date:** [March 6, 2019, 1:27pm UTC](https://discuss.elastic.co/t/one-row-from-postgres-table-inserted-into-elasticsearch/170883/3 "2019-03-06T13:27:56Z")

</div>

> select NMS\_NODE.name,nms\_node\_stat.cur\_stat from nms\_node,nms\_node\_stat where nms\_node.id = nms\_node\_stat.id

You query data with specific id.

---

<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:** [April 3, 2019, 1:28pm UTC](https://discuss.elastic.co/t/one-row-from-postgres-table-inserted-into-elasticsearch/170883/4 "2019-04-03T13:28:00Z")

</div>

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