Watcher Configuration to print results in Email

{
"watch_id": "serviceABC",
"node": "xGdwQzxQTryzn1x9u-KFhw",
"state": "executed",
"status": {
"state": {
"active": true,
"timestamp": "2018-06-20T04:28:XX.XX"
},
"last_checked": "2018-06-20T04:29:49.120Z",
"last_met_condition": "2018-06-20T04:29:49.120Z",
"actions": {
"send_email": {
"ack": {
"timestamp": "2018-06-20T04:29:16.567Z",
"state": "ackable"
},
"last_execution": {
"timestamp": "2018-06-20T04:29:49.120Z",
"successful": true
},
"last_successful_execution": {
"timestamp": "2018-06-20T04:29:49.120Z",
"successful": true
}
}
},
"execution_state": "executed",
"version": -1
},
"trigger_event": {
"type": "schedule",
"triggered_time": "2018-06-20T04:29:49.120Z",
"schedule": {
"scheduled_time": "2018-06-20T04:29:48.758Z"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"index_name-*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "my_fieldname: [0.2 TO ]"
}
},
{
"range": {
"@timestamp": {
"gte": "now-7d"
}
}
}
]
}
},
"_source": [
"message"
],
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gte": 1
}
}
},
"metadata": {
"name": "CPU util. check",
"xpack": {
"type": "json"
}
},
"result": {
"execution_time": "2018-06-20T04:29:XX.XX",
"execution_duration": 598,
"input": {
"type": "search",
"status": "success",
"payload": {
"_shards": {
"total": 22,
"failed": 0,
"successful": 22,
"skipped": 0
},
"hits": {
"hits": [
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "gM5xG2QBlZxOw2VhYARB",
"sort": [
1529468771416
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "Js5xG2QBlZxOw2VhVQSi",
"sort": [
1529468768641
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529468406117
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529468165110
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529468046117
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529468036117
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529467871416
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529467868641
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529467718641
],
"_score": null
},
{
"_index": "my_index-2018.06.20",
"_type": "doc",
"_source": {},
"_id": "xxxx",
"sort": [
1529467708641
],
"_score": null
}
],
"total": 6715,
"max_score": null
},
"took": 86,
"timed_out": false
},
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"my_index-
"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "my_field : [0.2 TO *]"
}
},
{
"range": {
"@timestamp": {
"gte": "now-7d"
}
}
}
]
}
},
"_source": [
"message"
],
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
},
"condition": {
"type": "compare",
"status": "success",
"met": true,
"compare": {
"resolved_values": {
"ctx.payload.hits.total": 6715
}
}
},
"actions": [
{
"id": "send_email",
"type": "email",
"status": "success",
"email": {
"account": "smtp_account",
"message": {
"id": "watcher_ID_xxxxx-2018-06-20T04:29:49.120Z",
"from": "xyzemail@abc.com",
"sent_date": "2018-06-20T04:29:49.xx.xx",
"to": [
"myemail@abc.com"
],
"subject": "High CPU Utilization in past 7 days",
"body": {
"text": " "
}
}
}
}
]
},
"messages": []
}