# Painless maxLoopCounter

**URL:** <https://discuss.elastic.co/t/painless-maxloopcounter/96692>\
**Category:** Elasticsearch\
**Created:** [August 11, 2017, 3:46am UTC](https://discuss.elastic.co/t/painless-maxloopcounter/96692 "2017-08-11T03:46:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlds](https://avatars.discourse-cdn.com/v4/letter/n/58956e/32.png) [@nlds](https://discuss.elastic.co/u/nlds)\
**Post date:** [August 11, 2017, 3:46am UTC](https://discuss.elastic.co/t/painless-maxloopcounter/96692/1 "2017-08-11T03:46:38Z")

</div>

Hi guys,

I'm trying to build funnel using scripted\_metric aggregation.  
I got the error "painless script loop maximum number of statements limit".  
I have to iterate through large number of events to count and calculate "time\_spent" between two steps.  
I read [https://github.com/elastic/elasticsearch/issues/22508](https://github.com/elastic/elasticsearch/issues/22508). The maxLoopCounter is 1M.  
Is there any chance that I can set maxLoopCounter ?

---

<div class="post-metadata">

**Author:** ![phanhongan](https://avatars.discourse-cdn.com/v4/letter/p/43a26b/32.png) [@phanhongan](https://discuss.elastic.co/u/phanhongan)\
**Post date:** [August 11, 2017, 8:20am UTC](https://discuss.elastic.co/t/painless-maxloopcounter/96692/2 "2017-08-11T08:20:15Z")

</div>

You can modify this number and re-compile the source code 😃

---

<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:** [September 8, 2017, 8:20am UTC](https://discuss.elastic.co/t/painless-maxloopcounter/96692/3 "2017-09-08T08:20:19Z")

</div>

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