# Elasticsearch as a Logstash input

**URL:** <https://discuss.elastic.co/t/elasticsearch-as-a-logstash-input/203493>\
**Category:** Logstash\
**Created:** [October 14, 2019, 4:53pm UTC](https://discuss.elastic.co/t/elasticsearch-as-a-logstash-input/203493 "2019-10-14T16:53:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_Nahata](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankit_nahata/32/55867_2.png) [@Ankit\_Nahata](https://discuss.elastic.co/u/Ankit_Nahata)\
**Post date:** [October 14, 2019, 4:53pm UTC](https://discuss.elastic.co/t/elasticsearch-as-a-logstash-input/203493/1 "2019-10-14T16:53:12Z")

</div>

Hi,  
Thanks for looking into this.!  
My problem: I need to get the count of documents in an elastic index every hour and store that back in another elastic index. Same I have to do for oracle and get the counts and store in an elastic index.  
This is to be done so that I can get the difference in the count of the data synced from ORA to ES (I am syncing data from ORA to ES).

My Approach: I am planning to use logstash to do so. I have created ORA query and am running it as an input in logstash to get the counts via JDBC driver(this works fine).  
Not I have to get the count from ES and store in the index, to do so I am taking logstash input from elastic search and running as a query. I just need the counts and pass that value to another ES index every hour.  
What query should I use to just return me the counts?

input {  
elasticsearch {  
hosts =\> "localhost"  
index =\> "elastictest\*"  
query =\> '  
{  
"query": {  
"match\_all": {}  
}  
}  
'  
}  
}

output {

```
elasticsearch {
   hosts => ["http://localhost:9200/"]
   index => "elastictest-%{+YYYY.MM}"
 }
stdout{}

```

}

---

<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:** [November 11, 2019, 4:53pm UTC](https://discuss.elastic.co/t/elasticsearch-as-a-logstash-input/203493/2 "2019-11-11T16:53:13Z")

</div>

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