# Continuous query

**URL:** <https://discuss.elastic.co/t/continuous-query/170908>\
**Category:** Elasticsearch\
**Created:** [March 5, 2019, 1:16pm UTC](https://discuss.elastic.co/t/continuous-query/170908 "2019-03-05T13:16:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![davtex](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@davtex](https://discuss.elastic.co/u/davtex)\
**Post date:** [March 5, 2019, 1:16pm UTC](https://discuss.elastic.co/t/continuous-query/170908/1 "2019-03-05T13:16:22Z")

</div>

Hello,

I am trying to replace InfluxDB with Elasticsearch and so far I've been 95% successful. The only thing I am struggling with is connected to our use of InfluxDB's "continuous queries".

In InfluxDB:  
We run a CQ to calculate a success rate. Every minute, InfluxDB itself runs a query where it selects all approved transactions (RESULT:APPROVED) and divides them by number of all transactions( no filter). The value is then saved to new measurement.

In Elasticsearch:  
I would like to do the same. I would like Elasticsearch to run, each 60s, 2 queries (count total, count approved), do some calculation (divide second one by first one) and save the result to new index(e.g. index:"rates", fields(rate\_type=success\_rate, rate\_result=\<calculated\_value).

Is something like this possible in current version? If not, I could still make some small python script that would do all of this for me, but it would be neat of this could be done directly by ES.

Regards,  
David

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 5, 2019, 5:06pm UTC](https://discuss.elastic.co/t/continuous-query/170908/2 "2019-03-05T17:06:37Z")

</div>

Alerting feature (commercial) might be one answer for this.  
Also checkout the new rollup feature which might be what you are looking for.

---

<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 2, 2019, 5:06pm UTC](https://discuss.elastic.co/t/continuous-query/170908/3 "2019-04-02T17:06:39Z")

</div>

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