First - thanks for your valuable reply and giving you the watch API execution with error
Watch API Execution:
POST _xpack/watcher/watch/mem_watch/_execute
#! Deprecation: [groovy] scripts are deprecated, use [painless] scripts instead
{
"_id": "mem_watch_f0c6931a-6cb5-4d6c-a1f8-8c9b764478eb-2017-11-28T23:05:24.878Z",
"watch_record": {
"watch_id": "mem_watch",
"state": "failed",
"trigger_event": {
"type": "manual",
"triggered_time": "2017-11-28T23:05:24.878Z",
"manual": {
"schedule": {
"scheduled_time": "2017-11-28T23:05:24.878Z"
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
".marvel-es-1-"
],
"types": [
"node_stats"
],
"body": {
"size": 0,
"query": {
"bool": {
"filter": {
"range": {
"timestamp": {
"gte": "now-2m",
"lte": "now"
}
}
}
}
},
"aggs": {
"minutes": {
"date_histogram": {
"field": "timestamp",
"interval": "minute"
},
"aggs": {
"nodes": {
"terms": {
"field": "source_node.name",
"size": 10,
"order": {
"memory": "desc"
}
},
"aggs": {
"memory": {
"avg": {
"field": "node_stats.jvm.mem.heap_used_percent"
}
}
}
}
}
}
}
}
}
}
},
"condition": {
"script": {
"inline": "if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false; def latest = ctx.payload.aggregations.minutes.buckets[-1]; def node = latest.nodes.buckets[0]; return node && node.memory && node.memory.value >= 75;",
"lang": "groovy"
}
},
"result": {
"execution_time": "2017-11-28T23:05:24.878Z",
"execution_duration": 1,
"input": {
"type": "search",
"status": "success",
"payload": {
"_shards": {
"total": 0,
"failed": 0,
"successful": 0
},
"hits": {
"hits": [],
"total": 0,
"max_score": 0
},
"took": 1,
"timed_out": false
},
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
".marvel-es-1-"
],
"types": [
"node_stats"
],
"body": {
"size": 0,
"query": {
"bool": {
"filter": {
"range": {
"timestamp": {
"gte": "now-2m",
"lte": "now"
}
}
}
}
},
"aggs": {
"minutes": {
"date_histogram": {
"field": "timestamp",
"interval": "minute"
},
"aggs": {
"nodes": {
"terms": {
"field": "source_node.name",
"size": 10,
"order": {
"memory": "desc"
}
},
"aggs": {
"memory": {
"avg": {
"field": "node_stats.jvm.mem.heap_used_percent"
}
}
}
}
}
}
}
}
}
}
},
"actions": []
},
"exception": {
"type": "script_exception",
"reason": "error evaluating if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false; def latest = ctx.payload.aggregations.minutes.buckets[-1]; def node = latest.nodes.buckets[0]; return node && node.memory && node.memory.value >= 75;",
"script_stack": [],
"script": "",
"lang": "groovy",
"caused_by": {
"type": "null_pointer_exception",
"reason": "Cannot get property 'minutes' on null object",
"stack_trace": """
java.lang.NullPointerException: Cannot get property 'minutes' on null object
at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:228)
at d76474fa78ba7805fc9568d7f3bc44ec409afce0.run(d76474fa78ba7805fc9568d7f3bc44ec409afce0:1)
at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript$$Lambda$1951/1806137276.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at