# Getting error in JSON advance for groovy dynamic script?

**URL:** <https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836>\
**Category:** Kibana\
**Created:** [February 26, 2016, 9:49am UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836 "2016-02-26T09:49:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chandni007](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@chandni007](https://discuss.elastic.co/u/chandni007)\
**Post date:** [February 26, 2016, 9:49am UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/1 "2016-02-26T09:49:32Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [February 26, 2016, 10:29pm UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/2 "2016-02-26T22:29:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chandni007](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@chandni007](https://discuss.elastic.co/u/chandni007)\
**Post date:** [February 29, 2016, 4:40am UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/3 "2016-02-29T04:40:25Z")

</div>

Hi Lee,

Thank you for your reply 🙂  
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

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [February 29, 2016, 3:11pm UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/4 "2016-02-29T15:11:22Z")

</div>

Can you show the error?

---

<div class="post-metadata">

**Author:** ![chandni007](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@chandni007](https://discuss.elastic.co/u/chandni007)\
**Post date:** [March 4, 2016, 3:55am UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/5 "2016-03-04T03:55:15Z")

</div>

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 🙂 but not getting it how to solve it ?

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [March 4, 2016, 4:03pm UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/6 "2016-03-04T16:03:06Z")

</div>

> [@chandni007](#):
>
> No field found for [node.ifs.bytes.used] ...

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:00pm UTC](https://discuss.elastic.co/t/getting-error-in-json-advance-for-groovy-dynamic-script/42836/7 "2017-07-06T14:00:13Z")

</div>


