# Round value in alert message

**URL:** <https://forum.opensearch.org/t/round-value-in-alert-message/9091>\
**Category:** Alerting\
**Tags:** configure\
**Created:** [March 31, 2022, 2:54am UTC](https://forum.opensearch.org/t/round-value-in-alert-message/9091 "2022-03-31T02:54:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakesh0696](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rakesh0696](https://forum.opensearch.org/u/rakesh0696)\
**Post date:** [March 31, 2022, 2:54am UTC](https://forum.opensearch.org/t/round-value-in-alert-message/9091/1 "2022-03-31T02:54:27Z")

</div>

Hello All,

We are trying achieve math round on aggregated results from monitor in alert message.  
Here is our Monitor Response:

```auto
{
    "_shards": {
        "total": 1,
        "failed": 0,
        "successful": 1,
        "skipped": 0
    },
    "hits": {
        "hits": [],
        "total": {
            "value": 124,
            "relation": "eq"
        },
        "max_score": null
    },
    "took": 5,
    "timed_out": false,
    "aggregations": {
        "route": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
                {
                    "avg_responsetime": {
                        "value": 57.06632846593857
                    },
                    "doc_count": 64,
                    "key": "Direct"
                },
                {
                    "avg_responsetime": {
                        "value": 98.60404980977377
                    },
                    "doc_count": 60,
                    "key": "Indirect"
                }
            ]
        }
    }
}

```

The Trigger Message we are trying is – **Actual : {{ctx.results.0.aggregations.route.buckets.0.avg\_resp.value}} Secs**  
This results like _ **Actual : 73.47249984741211 Secs** _.  
But the results expected is _ **Actual : 73.47 Secs** _

Please any one help me how to get round in painless code / Mustache / Monitor Query.

Reg,  
Rakesh

---

<div class="post-metadata">

**Author:** ![rakesh0696](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rakesh0696](https://forum.opensearch.org/u/rakesh0696)\
**Post date:** [October 11, 2022, 3:57am UTC](https://forum.opensearch.org/t/round-value-in-alert-message/9091/2 "2022-10-11T03:57:34Z")

</div>

I found work around for this with bucket\_script aggregation on existing aggregation in Monitor DSL Query.

```auto
{
  "size": 0,
  "aggs": {
    "transaction": {
      "terms": {
        "field": "TransactionName.keyword",
        "size": 10
      },
      "aggs": {
        "avg_resp": {
          "avg": {
            "field": "ResponseTime"
          }
        },
        "avg_resp_f": {
          "bucket_script": {
            "buckets_path": {"v1":"avg_resp"},
            "script": "Math.round(params.v1*100.00)/100.00"
          }
        }
      }
    }
  }
}

```

Reg,  
Rakesh
