# Scripted field to calculate a machine score

**URL:** <https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657>\
**Category:** Kibana\
**Created:** [March 29, 2021, 1:06pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657 "2021-03-29T13:06:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ITchandj](https://avatars.discourse-cdn.com/v4/letter/i/f19dbf/32.png) [@ITchandj](https://discuss.elastic.co/u/ITchandj)\
**Post date:** [March 29, 2021, 1:06pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/1 "2021-03-29T13:06:31Z")

</div>

Hallo !!!  
i want to write a scripted field that can calculate a machine score in kibana.. Please any idea how i can resolve it.  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [March 29, 2021, 1:46pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/2 "2021-03-29T13:46:27Z")

</div>

A scripted field can use all data which is stored in a single document (no cross-document calculations). What exactly should your machine score do?

---

<div class="post-metadata">

**Author:** ![ITchandj](https://avatars.discourse-cdn.com/v4/letter/i/f19dbf/32.png) [@ITchandj](https://discuss.elastic.co/u/ITchandj)\
**Post date:** [March 29, 2021, 4:08pm UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/3 "2021-03-29T16:08:11Z")

</div>

I would like to have something like in the screenshot ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2e9897490ab9e46cd81df6f9609c8d7c364a6382.png)

- **Machine score** : quality indicator for machine performance and health

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [March 30, 2021, 6:50am UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/4 "2021-03-30T06:50:46Z")

</div>

Scripted fields are a low-level technology which allows you to do calculations based on multiple fields within a document. It doesn't offer formulas like machine score out of the box. You will need to come up with a formula based on the fields you have, then I can help you transforming it into a scripted field.

---

<div class="post-metadata">

**Author:** ![ITchandj](https://avatars.discourse-cdn.com/v4/letter/i/f19dbf/32.png) [@ITchandj](https://discuss.elastic.co/u/ITchandj)\
**Post date:** [March 30, 2021, 7:19am UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/5 "2021-03-30T07:19:41Z")

</div>

thank you Very much for the answers. the follow values are used to show a machine score visualisation.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/f/9fbb250ea700ef7c54b49a3871fc8b7bc08305d5.png)

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [March 30, 2021, 7:37am UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/6 "2021-03-30T07:37:18Z")

</div>

This looks like a splunk expression - I'm not too familiar with them, but it looks like machinescore is just a regular field in your data, so you wouldn't need to do anything special, just do an average of the `MachineScore` field.

To do the over time comparison, make yourself familiar with the TSVB visualization: [TSVB | Kibana Guide [7.12] | Elastic](https://www.elastic.co/guide/en/kibana/7.12/tsvb.html)

---

<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:** [April 27, 2021, 7:37am UTC](https://discuss.elastic.co/t/scripted-field-to-calculate-a-machine-score/268657/7 "2021-04-27T07:37:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
