# Count API returning zero intermittely

**URL:** <https://discuss.elastic.co/t/count-api-returning-zero-intermittely/224145>\
**Category:** Elasticsearch\
**Created:** [March 18, 2020, 3:58pm UTC](https://discuss.elastic.co/t/count-api-returning-zero-intermittely/224145 "2020-03-18T15:58:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Senthil\_ak](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Senthil\_ak](https://discuss.elastic.co/u/Senthil_ak)\
**Post date:** [March 18, 2020, 3:58pm UTC](https://discuss.elastic.co/t/count-api-returning-zero-intermittely/224145/1 "2020-03-18T15:58:10Z")

</div>

I have a alert check on my elastic search for last 5 min count, if its zero then its send email alert.

The problem is elastic search intermittently returning zero count for last 5 min count. The curl url is

`curl --header "Content-Type:application/json" -d '{"query": {"range" : {"@timestamp" : {"gte" : "now-5m", "lt" : "now"}}}}' http://<elk_ulr>/_all/_count`

If hit this url continuously below are the results ....

```
{"count":0,"_shards":{"total":432,"successful":432,"skipped":0,"failed":0}}
{"count":0,"_shards":{"total":432,"successful":432,"skipped":0,"failed":0}}
{"count":170482,"_shards":{"total":432,"successful":432,"skipped":0,"failed":0}}
{"count":170270,"_shards":{"total":432,"successful":432,"skipped":0,"failed":0}}
{"count":169230,"_shards":{"total":432,"successful":432,"skipped":0,"failed":0}}

```

Why i am getting some time zero and some time count. Please help me on this inconsistency.

---

<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 15, 2020, 3:58pm UTC](https://discuss.elastic.co/t/count-api-returning-zero-intermittely/224145/2 "2020-04-15T15:58:12Z")

</div>

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