When attempting to using a sub aggregation metric average in a condition, I'm receiving
"aggregations": { "modules": { "terms": { "field": "host.hostname.keyword", "size": 8, "min_doc_count": 1 }, "aggregations": { "metricAgg": { "avg": { "field": "elapsed_time" } } } } }
I'm receiving the following results which provides the metricAgg value that I'm intending to use in a condition but when I attempting to perform a calculation, I'm getting an error as shown below.
        "aggregations": {
          "modules": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "doc_count": 218,
                "metricAgg": {
                  "value": 1.8669724770642202
                },
                "key": "server1"
              }
This is the error returning when attempting to Simulate the watcher.
  "exception": {
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "ctx.payload.metricAgg.value >= 1",
      "                     ^---- HERE"
    ],
    "script": "ctx.payload.metricAgg.value >= 1",
    "lang": "painless",
    "position": {
      "offset": 21,
      "start": 0,
      "end": 32
    },
    "caused_by": {
      "type": "null_pointer_exception",
      "reason": "cannot access method/field [value] from a null def reference",
My painless script condition is shown below:
  "condition": {
    "script": {
      "source": "ctx.payload.metricAgg.value >= 1",
      "lang": "painless"
    }
  },