Hi Alex,
Here the output. I have suppressed some result due to the length restriction
{
"_id": "W20171024_1faf2d76-cf08-4563-9c29-99387238a7c6-2017-10-26T12:37:31.805Z",
"watch_record": {
"watch_id": "W20171024",
"state": "executed",
"status": {
"state": {
"active": true,
"timestamp": "2017-10-26T12:37:27.849Z"
},
"last_checked": "2017-10-26T12:37:31.805Z",
"last_met_condition": "2017-10-26T12:37:31.805Z",
"actions": {
"my-logging-action": {
"ack": {
"timestamp": "2017-10-26T12:37:31.805Z",
"state": "ackable"
},
"last_execution": {
"timestamp": "2017-10-26T12:37:31.805Z",
"successful": true
},
"last_successful_execution": {
"timestamp": "2017-10-26T12:37:31.805Z",
"successful": true
}
}
}
},
"trigger_event": {
"type": "manual",
"triggered_time": "2017-10-26T12:37:31.805Z",
"manual": {
"schedule": {
"scheduled_time": "2017-10-26T12:37:31.805Z"
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"new_sbc"
],
"types": [],
"body": {
"query": {
"bool": {
"filter": [
{
"terms": {
"oper.keyword": [
"START",
"STOP"
]
}
},
{
"range": {
"@timestamp": {
"gte": "2017-10-04T20:46:00.000Z",
"lte": "2017-10-04T20:46:30.000Z"
}
}
}
]
}
},
"size": 0,
"aggs": {
"origin": {
"terms": {
"field": "from.keyword",
"size": 10000,
"min_doc_count": 2
},
"aggs": {
"call_ref": {
"terms": {
"field": "call_ref.keyword",
"size": 10000,
"min_doc_count": 2
},
"aggs": {
"total_duration": {
"sum": {
"field": "duration"
}
}
}
},
"grand_total": {
"sum_bucket": {
"buckets_path": "call_ref>total_duration"
}
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "def docs=[];def status= false;def calls=ctx.payload.aggregations.origin;for (int i = 0; i < calls.size(); ++i) {if (calls.buckets[i].grand_total.value > 34){ docs.add(['from' : calls.buckets[i].key , 'gt' : calls.buckets[i].grand_total.value]);status=true} } ctx.vars.alerts=docs; return status",
"lang": "painless"
}
},
"metadata": {
"name": "Watcher_test_1"
},
"result": {
"execution_time": "2017-10-26T12:37:31.805Z",
"execution_duration": 41,
"input": {
"type": "search",
"status": "success",
"payload": {
"_shards": {
"total": 5,
"failed": 0,
"successful": 5,
"skipped": 0
},
"hits": {
"hits": [],
"total": 73,
"max_score": 0
},
"took": 39,
"timed_out": false,
"aggregations": {
"origin": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"doc_count": 4,
"call_ref": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"doc_count": 2,
"total_duration": {
"value": 3
},
"key": "08cQ129462004118bcGhEfEpJll"
},
{
"doc_count": 2,
"total_duration": {
"value": 4
},
"key": "M7bV6124620041K7bcGhEfEjGmg"
}
]
},
"grand_total": {
"value": 7
},
"key": "376343543"
},
......