# Scripted Metric Aggregation

**URL:** <https://discuss.elastic.co/t/scripted-metric-aggregation/28623>\
**Category:** Elasticsearch\
**Created:** [September 3, 2015, 3:29pm UTC](https://discuss.elastic.co/t/scripted-metric-aggregation/28623 "2015-09-03T15:29:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hornov](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Hornov](https://discuss.elastic.co/u/Hornov)\
**Post date:** [September 3, 2015, 3:29pm UTC](https://discuss.elastic.co/t/scripted-metric-aggregation/28623/1 "2015-09-03T15:29:27Z")

</div>

When I try to use Scripted Metric Aggregation I've the error message : Unable to find on disk script.  
However my script files are in /etc/elasticsearch, where I put my others scripts files that I use with success for script fields or for cardinality aggregations. And my scripts have the groovy extension.  
How to do ?

my query is :  
"query" : {  
"match\_all" : {}  
},  
"aggs": {  
"profit": {  
"scripted\_metric": {  
"init\_script\_file" : "init\_script\_file",  
"map\_script\_file" : "map\_script\_file",  
"combine\_script\_file" : "combine\_script\_file",  
"reduce\_script\_file" : "reduce\_script\_file"  
}  
}  
}

and my script files follow : [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html)

---

<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:** [July 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/scripted-metric-aggregation/28623/2 "2017-07-05T23:52:13Z")

</div>


