Trying to execute the below query from Watcher in Kibana to get the result of result.input.payload.hits.total from Watcher history (last executed) and getting Null Value in result.
ctx.payload.hits.hits._source.result.input.payload.hits.total - -getting NULL value
I'm trying to get the total value as "total": 11689"
{
"trigger": {
"schedule": {
"interval": "30m"
}
},
"input": {
"search": {
"request": {
"body": {
"query" : {
"match" : { "watch_id": "test_watcher" }
},
"_source": "result.input.payload.hits.total",
"sort" : [
{ "result.execution_time" : "desc" }
],
"size": 1
},
"indices": [
".watcher-history-9-2020.05.13"
]
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.hits._source.result.input.payload.hits.total": {
"gte": 10
}
}
},
"actions": {
"my-logging-action": {
"logging": {
"text": "There are {{ctx.payload.hits.total}} documents in your index. Threshold is 10."
}
}
}
}
Output
{
"watch_id": "_inlined_",
"node": "khjqRl2ZQcm74yMp8nDFGg",
"state": "execution_not_needed",
"user": "testuser",
"status": {
"state": {
"active": true,
"timestamp": "2020-05-13T08:21:26.542Z"
},
"last_checked": "2020-05-13T08:21:26.542Z",
"actions": {
"my-logging-action": {
"ack": {
"timestamp": "2020-05-13T08:21:26.542Z",
"state": "awaits_successful_execution"
}
}
},
"execution_state": "execution_not_needed",
"version": -1
},
"trigger_event": {
"type": "manual",
"triggered_time": "2020-05-13T08:21:26.542Z",
"manual": {
"schedule": {
"scheduled_time": "2020-05-13T08:21:26.542Z"
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
".watcher-history-9-2020.05.13"
],
"types": [],
"body": {
"query": {
"match": {
"watch_id": "test_watcher"
}
},
"_source": "result.input.payload.hits.total",
"sort": [
{
"result.execution_time": "desc"
}
],
"size": 1
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.hits._source.result.input.payload.hits.total": {
"gte": 10
}
}
},
"metadata": {
"xpack": {
"type": "json"
}
},
"result": {
"execution_time": "2020-05-13T08:21:26.542Z",
"execution_duration": 1,
"input": {
"type": "search",
"status": "success",
"payload": {
"_shards": {
"total": 1,
"failed": 0,
"successful": 1,
"skipped": 0
},
"hits": {
"hits": [
{
"_index": ".watcher-history-9-2020.05.13",
"_type": "doc",
"_source": {
"result": {
"input": {
"payload": {
"hits": {
"total": 11689
}
}
}
}
},
"_id": "test_watcher_5e27d70e-a8bf-474c-ae1a-3e2ab34a8803-2020-05-13T08:21:00.335Z",
"sort": [
1589358060335
],
"_score": null
}
],
"total": 227,
"max_score": null
},
"took": 0,
"timed_out": false
},
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
".watcher-history-9-2020.05.13"
],
"types": [],
"body": {
"query": {
"match": {
"watch_id": "test_watcher"
}
},
"_source": "result.input.payload.hits.total",
"sort": [
{
"result.execution_time": "desc"
}
],
"size": 1
}
}
}
},
"condition": {
"type": "compare",
"status": "success",
"met": false,
"compare": {
"resolved_values": {
"ctx.payload.hits.hits._source.result.input.payload.hits.total": null
}
}
},
"actions": []
},
"messages": []
}