# Not so painless script: max of time-series

**URL:** <https://discuss.elastic.co/t/not-so-painless-script-max-of-time-series/91449>\
**Category:** Elasticsearch\
**Created:** [June 30, 2017, 2:19pm UTC](https://discuss.elastic.co/t/not-so-painless-script-max-of-time-series/91449 "2017-06-30T14:19:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregbk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregbk/32/80289_2.png) [@gregbk](https://discuss.elastic.co/u/gregbk)\
**Post date:** [June 30, 2017, 2:19pm UTC](https://discuss.elastic.co/t/not-so-painless-script-max-of-time-series/91449/1 "2017-06-30T14:19:33Z")

</div>

Hello,

I have trouble finding documentation for paintless script. [https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-painless.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-painless.html)  
I don't know java nor groovy. I just wanted to do a max of 3 values in a gauge.  
So I will display 99% red color if one one of CPU, SWAP, DISK goes to 99%.

Anyone can help me find examples?

 ![](https://us1.discourse-cdn.com/elastic/original/3X/2/2/2207193494ccecc158898afdc15ab6bbeaba89fa.png)

Thanks for your help!  
Greg

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 7, 2017, 1:26pm UTC](https://discuss.elastic.co/t/not-so-painless-script-max-of-time-series/91449/2 "2017-07-07T13:26:21Z")

</div>

I think this should work for you:

```auto
Math.max(params.swap, Math.max(params.cpu, params.disk))

```

Painless is a pass-through for a lot of basic java functions (like `Math.max()`), hence the syntax in this case 🙂

---

<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:** [August 4, 2017, 1:27pm UTC](https://discuss.elastic.co/t/not-so-painless-script-max-of-time-series/91449/3 "2017-08-04T13:27:00Z")

</div>

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