# Custom aggregation and script inside of Kibana

**URL:** <https://discuss.elastic.co/t/custom-aggregation-and-script-inside-of-kibana/56817>\
**Category:** Kibana\
**Created:** [July 31, 2016, 10:45am UTC](https://discuss.elastic.co/t/custom-aggregation-and-script-inside-of-kibana/56817 "2016-07-31T10:45:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clioharp](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@clioharp](https://discuss.elastic.co/u/clioharp)\
**Post date:** [July 31, 2016, 10:45am UTC](https://discuss.elastic.co/t/custom-aggregation-and-script-inside-of-kibana/56817/1 "2016-07-31T10:45:45Z")

</div>

Hi all,

I'm working on an aggregation for an API management tool and we'd like to see how many requests per user each app using our API tool uses. I've written the code already as an ElasticSearch query but I can't figure out how to translate it into something that would be a Kibana visualization. Any ideas?

[code]{  
"size":0,  
"aggregations": {  
"apps": {  
"terms": {  
"field": "application\_name"  
},  
"aggregations" : {  
"user\_count" : {  
"cardinality" : {  
"field" : "user\_id"  
}  
},  
"total\_request" : {  
"value\_count" : {  
"field" : "created\_at"  
}  
} ,  
"avg\_request\_per\_app" : {  
"bucket\_script": {  
"buckets\_path": {  
"totalUsers": "user\_count",  
"totalRequest": "total\_request"  
},  
"script": "totalRequest / totalUsers"  
}  
}

```
    } 
  }

```

}

}[/code]

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [August 1, 2016, 4:41pm UTC](https://discuss.elastic.co/t/custom-aggregation-and-script-inside-of-kibana/56817/2 "2016-08-01T16:41:35Z")

</div>

Unfortunately pipeline aggregations are not yet supported in Kibana. There is an issue open for it, though, if you want to follow its progress: [https://github.com/elastic/kibana/issues/4584](https://github.com/elastic/kibana/issues/4584).

---

<div class="post-metadata">

**Author:** ![clioharp](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@clioharp](https://discuss.elastic.co/u/clioharp)\
**Post date:** [August 2, 2016, 8:09am UTC](https://discuss.elastic.co/t/custom-aggregation-and-script-inside-of-kibana/56817/3 "2016-08-02T08:09:10Z")

</div>

Thanks for the reply! I'll keep an eye on the issue and in the meanwhile, let me know if I can help at all.

---

<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 6, 2017, 1:42pm UTC](https://discuss.elastic.co/t/custom-aggregation-and-script-inside-of-kibana/56817/4 "2017-07-06T13:42:29Z")

</div>


