Unable to run inline script from Kibana UI

The default scripting language in Kibana is Lucene Expressions, not Groovy, for security reasons. If you do decide to use Groovy, we recommend using static scripts... more on getting that working in this thread: Calling groovy script from Kibana