# Logstash pulls all records from postgres db not as per join

**URL:** <https://discuss.elastic.co/t/logstash-pulls-all-records-from-postgres-db-not-as-per-join/176895>\
**Category:** Logstash\
**Created:** [April 15, 2019, 11:52am UTC](https://discuss.elastic.co/t/logstash-pulls-all-records-from-postgres-db-not-as-per-join/176895 "2019-04-15T11:52:32Z")\
**Posts on this page:** 2\
**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:** [April 15, 2019, 11:52am UTC](https://discuss.elastic.co/t/logstash-pulls-all-records-from-postgres-db-not-as-per-join/176895/1 "2019-04-15T11:52:33Z")

</div>

Here is my logstash.conf file

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 =\> "password"  
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 =\> "45 \* \* \* \* \*"  
# our query  
statement =\> "select distinct nms\_node.name,nms\_node\_stat.cur\_stat,nms\_node\_cna.parent from nms\_node inner join nms\_node\_stat on nms\_node\_stat.id=nms\_node.id inner join nms\_node\_cna on nms\_node\_cna.parent=nms\_node.id where nms\_node\_cna.value like 'ITSEC'"  
}  
}  
output {  
elasticsearch {  
hosts =\> "localhost:9200"  
index =\> "itsec"  
document\_type =\> "itsecstatus"  
document\_id =\> "%{parent}"  
}  
stdout { codec =\> rubydebug }  
}

However when I check output of itsec index, I see all records are been pulled by logstash jdbc plugin.

If I run sql statement in Postgres it pulls only two records.

Please advise.

---

<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:** [May 13, 2019, 11:52am UTC](https://discuss.elastic.co/t/logstash-pulls-all-records-from-postgres-db-not-as-per-join/176895/2 "2019-05-13T11:52:48Z")

</div>

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