# Running an ESQL query periodally and output the result into an index

**URL:** <https://discuss.elastic.co/t/running-an-esql-query-periodally-and-output-the-result-into-an-index/351481>\
**Category:** Kibana\
**Created:** [January 20, 2024, 2:16pm UTC](https://discuss.elastic.co/t/running-an-esql-query-periodally-and-output-the-result-into-an-index/351481 "2024-01-20T14:16:39Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![lizozom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lizozom/32/114932_2.png) [@lizozom](https://discuss.elastic.co/u/lizozom)\
**Post date:** [January 23, 2024, 1:18pm UTC](https://discuss.elastic.co/t/running-an-esql-query-periodally-and-output-the-result-into-an-index/351481/7 "2024-01-23T13:18:13Z")

</div>

[xeraa](https://discuss.elastic.co/u/xeraa)  
I actually ended up doing something a bit different

1. I created a regular `Transform` that calculates today's inventory
2. I ran a simple `Watcher` that copies those entries to a new `Data stream`. See this [Q\A](https://discuss.elastic.co/t/use-watcher-index-action-with-multiple-documents/351503/2) for reference. It adds the inventory date as an extra field to each document, hence creating an inventory history index.
3. I then used `ES|QL` to query the inventory index.

So at this point, supporting `ESQL` to create that inventory data stream would be a cool addition, but no desperate measures needed to be taken!

Thanks 🙂

---

_[View the full topic](https://discuss.elastic.co/t/running-an-esql-query-periodally-and-output-the-result-into-an-index/351481)._
