# Scripted field return wrong value

**URL:** <https://discuss.elastic.co/t/scripted-field-return-wrong-value/38752>\
**Category:** Kibana\
**Created:** [January 8, 2016, 7:34pm UTC](https://discuss.elastic.co/t/scripted-field-return-wrong-value/38752 "2016-01-08T19:34:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![minh.hoang](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@minh.hoang](https://discuss.elastic.co/u/minh.hoang)\
**Post date:** [January 8, 2016, 7:34pm UTC](https://discuss.elastic.co/t/scripted-field-return-wrong-value/38752/1 "2016-01-08T19:34:11Z")

</div>

I'm trying to verify the CPU usage percentage for a box with topbeat with everything in default, only change I made is instead of output to elasticsearch, the output is logstash.

This is the scripted field:

![](https://us1.discourse-cdn.com/elastic/original/2X/c/c5abd9077f52611fcdb6515bcdcf414b02f39567.png)

script: doc['cpu.user\_p'].value

and this is the visualization to compare the CPU percentage of 2 field: cpu.user\_p and cpu\_user\_percentage (scripted field)

![](https://us1.discourse-cdn.com/elastic/original/2X/b/bd09240ed143dc3dc4e93bdbf1938edac8b5acbf.png)

while cpu.user\_p is correct, the scripted field return the wrong value although the format for both field are the same, and the script should give back the native value of cpu.user\_p field based on this documentation: [https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#\_document\_fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_document_fields)

Did I understand the scripted field wrong or it's a bug?

Thank you.

---

<div class="post-metadata">

**Author:** ![Khalah\_Jones\_Golden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khalah_jones_golden/32/7169_2.png) [@Khalah\_Jones\_Golden](https://discuss.elastic.co/u/Khalah_Jones_Golden)\
**Post date:** [January 11, 2016, 6:17pm UTC](https://discuss.elastic.co/t/scripted-field-return-wrong-value/38752/2 "2016-01-11T18:17:08Z")

</div>

Hey Minh,

Do you have spy panel screenshots, or json for me to look at?

Does it work if you use _source.cpu_.user\_p?

Have you tried it without the formatting as well?

---

<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:05pm UTC](https://discuss.elastic.co/t/scripted-field-return-wrong-value/38752/3 "2017-07-06T14:05:19Z")

</div>


