Query to determine percentage

Hi all,

I have a query that returns an aggregation for a certain term:

    {
      "_source": ["id", "status","message"],
      "query": {    
        "bool": {
          "must": [
    	{"exists": { "field": "status" }}
          ],
          "filter": [
            { "range": { "@timestamp": { "gte": "now-1h" }}}
          ]
        }
      },
      "aggs" : {	
        "distinct_status" : { "terms" : { "field" : "status" }}
      }
    }

The result includes:

    "hits": {
            "total": {
                "value": 193,
                "relation": "eq"
            },
    (...)
    "aggregations": {
            "mission_endings": {
                "doc_count_error_upper_bound": 0,
                "sum_other_doc_count": 0,
                "buckets": [
                    {
                        "key": "Success",
                        "doc_count": 141
                    },
                    {
                        "key": "Error",
                        "doc_count": 26
                    },
                    {
                        "key": "Warning",
                        "doc_count": 26
                    }
                ]
            }
        }

Is there a way to write a query that returns, for example, the ratio of Success / Total?

Thank you

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