Do calculations in kibana visualization JSON input

(Luís Ricardo da Costa Carvalho) #1


I´m trying to do script calculation using the result of a metric and a field in JSON input. I change the elasticsearch.yml configuration to allowed scripting adding: true
script.groovy.sandbox.enabled: true
script.inline: on
script.indexed: on true
script.engine.groovy.inline.aggs: true

_value is the result of a sum in kibana metrics visualization and in the same metric putting:

"script": " _value / 9"

in the JSON input, kibana gives the correct result. But if the script needs the value of a field like:

"script": "_value / doc['some-field'].value "

kibana don´t show the correct result or don´t give any result.

Some one can help me with this? Thanks!

(Tanya Bragin) #2

By default Kibana defaults to the Lucene expressions scripting language, so you need to include the "lang" : "groovy" parameter in your script. See example here Calling groovy script from Kibana

(Luís Ricardo da Costa Carvalho) #3

Thank you for your help! I try your solution, but for the division operator kibana don´t give any result.

kibana JSON input:

{ "script": "_value + doc['HTTP_Request'].value ", "lang" : "groovy" }

{ "script": "_value - doc['HTTP_Request'].value ", "lang" : "groovy" }

{ "script": "_value + 9", "lang" : "groovy" }

For sum, subtraction and divisions with a specific number it's ok.

{ "script": "_value / doc['HTTP_Request'].value ", "lang" : "groovy" }

But for this script kibana don´t show any result.


(Luís Ricardo da Costa Carvalho) #4

Basically I want to do some calculations like:

(∑MISS / ∑HTTP requests – ∑Manifests requests – ∑m3u8 requests) in Δt * 100%
But I don´t know if I can do this kind of formulas in Kibana or Elasticsearch.


(system) #5