# Too many dynamic script compilations within one minute, max: \[15/min\];

**URL:** <https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-one-minute-max-15-min/105244>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [October 25, 2017, 12:41pm UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-one-minute-max-15-min/105244 "2017-10-25T12:41:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![varun\_kumar2](https://avatars.discourse-cdn.com/v4/letter/v/97f17d/32.png) [@varun\_kumar2](https://discuss.elastic.co/u/varun_kumar2)\
**Post date:** [October 25, 2017, 12:41pm UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-one-minute-max-15-min/105244/1 "2017-10-25T12:41:13Z")

</div>

Here is the output with error  
{  
"\_id": "CRM.Email.Monitor.Errors\_d5a3faac-50c2-4238-929b-4e84088f9fd4-2017-10-25T12:36:16.292Z",  
"watch\_record": {  
"watch\_id": "CRM.Email.Monitor.Errors",  
"state": "failed",  
"\_status": {  
"state": {  
"active": true,  
"timestamp": "2017-10-25T12:36:10.942Z"  
},  
"actions": {  
"send\_email": {  
"ack": {  
"timestamp": "2017-10-25T12:36:10.942Z",  
"state": "awaits\_successful\_execabcon"  
}  
}  
}  
},  
"trigger\_event": {  
"type": "manual",  
"triggered\_time": "2017-10-25T12:36:16.292Z",  
"manual": {  
"schedule": {  
"scheduled\_time": "2017-10-25T12:36:16.292Z"  
}  
}  
},  
"input": {  
"search": {  
"request": {  
"search\_type": "query\_then\_fetch",  
"indices": [  
"logstash-_"  
],  
"types": [  
"logevent"  
],  
"body": {  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"level": "Error"  
}  
},  
{  
"match": {  
"fields.ApplicationSuite": "CRM"  
}  
},  
{  
"match": {  
"fields.ApplicationName": "CRMEmailMonitor"  
}  
},  
{  
"match\_phrase\_prefix": {  
"message": "There are Failed CRM Emails"  
}  
}  
],  
"filter": {  
"range": {  
"@timestamp": {  
"from": "now-16m",  
"to": "now"  
}  
}  
}  
}  
},  
"script\_fields": {  
"TimeStampFormatted": {  
"script": {  
"inline": "def sf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss');String dateStr = sf.format(doc['@timestamp'].value);"  
}  
},  
"LastEmailSentFormatted": {  
"script": {  
"inline": "def sf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss');String dateStr = sf.format(doc['fields.LastEmailSent'].value);"  
}  
},  
"ApplicationName": {  
"script": "\_source.fields.ApplicationName"  
},  
"FailedEmailCount": {  
"script": "\_source.fields.FailedEmailCount"  
}  
},  
"sort": [  
{  
"@timestamp": "desc"  
}  
],  
"size": 100  
}  
}  
}  
},  
"condition": {  
"script": {  
"inline": "def sf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss');String dateStr = sf.format(new Date());def dt = sf.parse(dateStr);Calendar cal = sf.getCalendar(); cal.setTime(dt);cal.add(Calendar.MINUTE, -16);def instant = cal.toInstant();def localDateTime = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);ctx.vars.from = localDateTime;return ctx.payload.hits.total\>0",  
"lang": "painless"  
}  
},  
"result": {  
"execabcon\_time": "2017-10-25T12:36:16.292Z",  
"execabcon\_duration": 907,  
"input": {  
"type": "search",  
"status": "failure",  
"reason": "SearchPhaseExecabconException[all shards failed]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max\_compilations\_per\_minute] setting]; ",  
"search": {  
"request": {  
"search\_type": "query\_then\_fetch",  
"indices": [  
"logstash-_"  
],  
"types": [  
"logevent"  
],  
"body": {  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"level": "Error"  
}  
},  
{  
"match": {  
"fields.ApplicationSuite": "CRM"  
}  
},  
{  
"match": {  
"fields.ApplicationName": "CRMEmailMonitor"  
}  
},  
{  
"match\_phrase\_prefix": {  
"message": "There are Failed CRM Emails"  
}  
}  
],  
"filter": {  
"range": {  
"@timestamp": {  
"from": "now-16m",  
"to": "now"  
}  
}  
}  
}  
},  
"script\_fields": {  
"TimeStampFormatted": {  
"script": {  
"inline": "def sf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss');String dateStr = sf.format(doc['@timestamp'].value);"  
}  
},  
"LastEmailSentFormatted": {  
"script": {  
"inline": "def sf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss');String dateStr = sf.format(doc['fields.LastEmailSent'].value);"  
}  
},  
"ApplicationName": {  
"script": "\_source.fields.ApplicationName"  
},  
"FailedEmailCount": {  
"script": "\_source.fields.FailedEmailCount"  
}  
},  
"sort": [  
{  
"@timestamp": "desc"  
}  
],  
"size": 100  
}  
}  
}  
},  
"actions": []  
},  
"messages": [  
"failed to execute watch input"  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 2, 2017, 9:17am UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-one-minute-max-15-min/105244/2 "2017-11-02T09:17:22Z")

</div>

the exception reason already states what to do: set `script.max_compilations_per_minute` to a higher value - I suppose you have several watches, that contain several scripts, also note that a few things, that internal are treated as a script are hard to spot, for example the whole request body of a search input.

Hope this helps!

--Alex

---

<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 30, 2017, 9:18am UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-one-minute-max-15-min/105244/3 "2017-11-30T09:18:04Z")

</div>

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