Hi,
I seem to have similar problem mentioned in Problem execute watcher "Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null"
Sample JSON:
        "aggs": {
                "unique_customerid": {
                  "terms": {
                    "field": "CustomerID.keyword"
                  }
                }
              }
            }
          }
        }
      },
      "condition": {
        "script": {
          "source": "return ctx.payload.aggregations.unique_customerid.buckets.stream().count() > 1",
          "lang": "painless"
        }
      },
In Kibana logs I see that CustomerID.keyword exists so I am not sure why I get nullpointer exception here in this condition.
  "exception": {
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "return ctx.payload.aggregations.unique_customerid.buckets.stream().count() > 1",
      "                               ^---- HERE"
    ],
    "script": "return ctx.payload.aggregations.unique_customerid.buckets.stream().count() > 1",
    "lang": "painless",
    "position": {
      "offset": 31,
      "start": 0,
      "end": 78
    },
    "caused_by": {
      "type": "null_pointer_exception",
      "reason": "Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null",
      "stack_trace": "java.lang.NullPointerException: Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null\n\tat