How can I do scripted aggregation in Kibana + Elasticsearch?

时间秒杀一切 提交于 2019-11-29 06:30:52

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/29174113/how-can-i-do-scripted-aggregation-in-kibana-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!