# Watcher - Action formating message

**URL:** <https://discuss.elastic.co/t/watcher-action-formating-message/203017>\
**Category:** Elasticsearch\
**Created:** [October 10, 2019, 12:34pm UTC](https://discuss.elastic.co/t/watcher-action-formating-message/203017 "2019-10-10T12:34:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesarlino](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@cesarlino](https://discuss.elastic.co/u/cesarlino)\
**Post date:** [October 10, 2019, 12:34pm UTC](https://discuss.elastic.co/t/watcher-action-formating-message/203017/1 "2019-10-10T12:34:26Z")

</div>

Hi,

I am playing with Watcher to setup an alert for certain threshold. If condition is met, then I want to send a message via Slack with the aggregated value. Everything is working perfectly, except the number looks like **0.9823284906645616**. I would like to format this number with only 2 decimal numbers. I am not sure how to achieve that or even if it is possible. Can I do this in the action side **{{ctx.payload.results.0.value}}**? Or do I need to make this in the transformation piece:

```
  "transform" : {
    "script" : {
      "source" : "HashMap result = new HashMap(); ArrayList arr = ctx.payload.aggregations.bucketAgg.buckets; ArrayList filteredHits = new ArrayList(); for (int i = 0; i < arr.length; i++) { HashMap filteredHit = new HashMap(); filteredHit.key = arr[i].key; filteredHit.value = arr[i]['metricAgg'].value; if (filteredHit.value < params.threshold) { filteredHits.add(filteredHit); } } result.results = filteredHits; return result;",
      "lang" : "painless",
      "params" : {
        "threshold" : 1.5
      }
    }
  }

```

Thanks,  
Cesar Lino

---

<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:** [November 7, 2019, 12:34pm UTC](https://discuss.elastic.co/t/watcher-action-formating-message/203017/2 "2019-11-07T12:34:40Z")

</div>

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