Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do scripted aggregation in Kibana + Elasticsearch?

Let's say I have a log of events of ad displays and ad clicks stored via Logstash in Elasticsearch and displayed in Kibana 4. I would like to calculate a simple metric like CTR (Click-Through-Rate) of the events , which is :

CTR = #clicks/#displays.

First of all, does anyone know if it's possible to do in Elasticsearch + Kibana? I don't see a possibility to do it in Kibana. I was thinking about doing it in raw Elasticsearch by scripted aggregation. But I don't know how to define such in Kibana.

Any ideas on how to do it would be very welcome! Comments explaining that it's impossible to do it would be also valuable.

like image 886
zarzyk Avatar asked Mar 20 '15 19:03

zarzyk


2 Answers

Kibana 4 includes support for Elasticsearch scripting. You can go to Settings > Indices (pick your pattern) > Scripted Fields and add a new scripted field that computes your CTR. Take a look at "Scripted Fields" at elastic blog for more info.

like image 104
Guido Avatar answered Oct 14 '22 05:10

Guido


I had to do something similar for a customer, but couldn't manage to get it done using scripted fields, because I had to sum UP all the values on each aggregation. I ended up developing a custom visualization (Plugin). This was for Kibana 4.1 and 4.5.1.

Let me know if this is what you are looking for, or if you want to give it a go yourself I can give you some pointers.

like image 30
JuanCarniglia Avatar answered Oct 14 '22 03:10

JuanCarniglia