Getting error in JSON advance for groovy dynamic script?

HI all,
I am getting this error while running groovy script in kibana 4 visualization
Visualize: failed to run inline script [doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value] using lang [groovy]
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"failed to run inline script [doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value] using lang [groovy]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"isilon","node":"stQM7IvdQ9uFMSRcp5oEhA","reason":{"type":"script_exception","reason":"failed to run inline script [doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value] using lang [groovy]","caused_by":{"type":"illegal_argument_exception","reason":"No field found for [node.ifs.bytes.used] in mapping with types []"}}}]}
at Array.map (native)
at Function.Promise.map
at callResponseHandlers

I have done this changes in elasticsearch.yml .
script.inline: true
script.engine.groovy.inline.aggs: true
script.engine.groovy.inline.mapping: true
script.engine.groovy.inline.search: true
script.engine.groovy.inline.update: false
script.engine.groovy.inline.plugin: false
script.engine.groovy.inline.aggs: on
script.engine.groovy.inline.mapping: on

and my script is

{"script":"doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value","lang":"groovy"
}

kindly help mee with this :slightly_smiling:

Hi Chandni

I'm not sure but I don't think you need to use or enable groovy scripting to get your percent bytes used. I think you can just create a scripted field in Kibana on the Settings tab and then use that field in your visualizations.

Here's an example of one I did just to try doing some math in a scripted field (it doesn't actually make any sense but it works).

doc['bytes'].value/1000 + doc['machine.ram'].value

When you go to create a scripted field there's a simple example on the page.

Regards,
Lee

1 Like

Hi Lee,

Thank you for your reply :slightly_smiling:
I tried to do this same but I'm getting error when I divide two values , an addition or any of the -,/,* is working well with one value and any other numbers .
Like doc[].values*8/(1024*1024)

Regards,
Chandni

Can you show the error?

Hello @LeeDr ,
sorry for late reply and following is my error:

Visualize: failed to run inline script [doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value] using lang [groovy] Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"failed to run inline script [doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value] using lang [groovy]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"isilon","node":"stQM7IvdQ9uFMSRcp5oEhA","reason":{"type":"script_exception","reason":"failed to run inline script [doc['node.ifs.bytes.used'].value * 100 / doc['node.ifs.bytes.total'].value] using lang [groovy]","caused_by":{"type":"illegal_argument_exception","reason":"No field found for [node.ifs.bytes.used] in mapping with types "}}}]} at Array.map (native) at Function.Promise.map at callResponseHandlers

This is the same error I specified earlier :slightly_smiling: but not getting it how to solve it ?

Hi Chandni,

Towards the end of that error its saying that field isn't found. Can you do a simple test with just that field and see if that works?

Thanks,
Lee