Write a Scripted field that calculates a rate by dividing the count of 2 text fields

(Jeremy Colton) #1

I collect many events from websites and visualize them using Kibana. The events include page loaded", "image clicked". My Kibana index contains an 'event' field that stores these event text values.

I want to show a graph of CTR on the images, so:
total "image clicked" events / total number of all events.

Can I do this using a scripted field?

Many thanks.

(Lee Drengenberg) #2

Hi Jeremy,

I don't think you can do that with a scripted field in Kibana. Scripted fields can only use the numeric values in each individual document and it sounds like you want to use an aggregation of all the documents.

You might get what you are looking for by using the "Percentage" Chart Mode in the Options of your chart.

Also, I think the Timelion plugin for Kibana could probably show the ratio of the values to the aggregate count. Here's some links if you're not familiar with it;


The later the Kibana build you're on, the better the Kibana to Timelion integration is.


(Jeremy Colton) #3

Hi Lee,

Thanks for your reply...where do I find "percentage" chart mode eg for a histogram or line chart?

I've asked the creator of TimeLion how to do what I want as well since his video and page don't explain his new querying language.

(Lee Drengenberg) #4

Not all chart types have Percentage in their Options. A Line chart does not. For the chart types that do have it, you can find it in the options tab.

(Jeremy Colton) #5


Or even a pie chart will do - it provides percentages per slice!

Can TimeLion visuals be saved and used in a dashboard like regular visuals?

Many thanks.

(Lee Drengenberg) #6

Hi Jeremy,

You can use Timelion charts in Kibana 4.5 dashboards. After you install the TimeLion plugin into Kibana you can create a new "Timeseries" visualization (on the Kibana Visualize tab). And you can add that to your Dashboard.

When you're in the TimeLion plugin you can create charts and save sheets, but you cannot put those in a Kibana Dashboard.

(system) #7