Rounding aggregate value

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 !

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"
              }
            }
          }
        }
      }
    }
  }
}

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