Arithmetic operations on count result


Hi All,

I'm new to kibana ( Kibana 4.5) and I would like to know, if there a way to apply a simple math operation on count result like multiplication or division.

I tried to add a script_fields on JSON input by following the documentation but it does not work...

My goal is to multiply this result ( see Example below)

Thanks for your help.


(Tyler Smalley) #2

If you wanted to say, multiply the count by two. One way to accomplish this would be to use a scripted field. In Settings > Indices > Scripted Fields create a new field with the script simply being "2".

You can then create a metric to SUM the new scripted field.


I am able to multiply a numeric field with this script :

doc['numeric_field'].value * 2

but my goal is to multiply a count result query ( with a non-numeric field)
eg: Multiply unique count of client_id ( client_id is not a numeric document)

Visualize: Field [client_id] used in expression must be numeric

I'm not sur if we can do this with Kibana right now.



(Tyler Smalley) #4

Try setting the script to "2", then using SUM instead of COUNT

(Bharath) #5

Did you tried in JSONInput like this {"script":"_value*2"} to multiply the output?(in this case to get 2 times the Unique count of ClientId )

(Dan ) #6

wow, great recommendation really helped me.
what else can be done with the json script?

(system) #7