Do calculations in kibana visualization JSON input

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