# Rounding aggregate value

**URL:** <https://discuss.elastic.co/t/rounding-aggregate-value/246678>\
**Category:** Elasticsearch\
**Created:** [August 27, 2020, 6:56pm UTC](https://discuss.elastic.co/t/rounding-aggregate-value/246678 "2020-08-27T18:56:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newKibanaUser](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@newKibanaUser](https://discuss.elastic.co/u/newKibanaUser)\
**Post date:** [August 27, 2020, 6:56pm UTC](https://discuss.elastic.co/t/rounding-aggregate-value/246678/1 "2020-08-27T18:56:36Z")

</div>

I have this query and want "avg\_disk\_usage" to have two decimal values. I am on Elasticsearch version 7.8. Can someone give me a workable fix? Thanks !

```auto
GET .monitoring-es*/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "type": "node_stats"
          }
        },
        {
          "term" : {
            "cluster_uuid" : {
              "value" : "6dM4HoQ1Su6AwmBugAisVg"
            }
          }
        },
        {
          "range": {
            "timestamp": {
              "gte": "now-60h"
            }
          }
        }
      ]
    }
  },
  "_source": {
    "includes": [
      "type",
      "cluster_uuid",
      "source_node.name",
      "node_stats.fs.total.free_in_bytes",
      "node_stats.fs.total.total_in_bytes"
    ]
  },
  "size": 1,
  "aggs": {
    "clusters": {
      "terms": {
        "field": "cluster_uuid",
        "size": 100
      },
      "aggs": {
        "nodes": {
          "terms": {
            "field": "source_node.name",
            "size": 100
          },
          "aggs": {
            "avg_disk_usage": {
              "avg": {
                "script": {
                  "lang": "expression",
                  "source": "100 - ((doc['node_stats.fs.total.free_in_bytes'].value / doc['node_stats.fs.total.total_in_bytes'].value) * 100)"
                }
              }
            },
            "cluster_uuid": {
              "terms": {
                "field": "cluster_uuid"
              }
            }
          }
        }
      }
    }
  }
}

```

---

<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:** [September 24, 2020, 6:56pm UTC](https://discuss.elastic.co/t/rounding-aggregate-value/246678/2 "2020-09-24T18:56:40Z")

</div>

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