Hi,
So I'm trying to create an email action that shows me weekly a summary of all the watches that I currently have running. I'm having trouble displaying it nicely though and it would be nice if I could display the results form my aggregation a bit nicer than what I can currently do.
POST _xpack/watcher/watch/currentActiveWatches
{
"trigger": {
"schedule": {
"interval": "5s"
}
},
"input": {
"http": {
"request": {
"host": "XXXXX",
"port": 9200,
"path": ".watcher-history*/_search",
"body": "{\"_source\": [\"watch_id\" ], \"query\": { \"wildcard\": { \"watch_id\": \"A*\" }},
\"aggs\": {\"distinct_watches\": { \"terms\": {\"field\": \"watch_id\", \"size\": 15 } }} }"
}
}
},
"actions": {
"send_email": {
"email": {
"from": "XX@X.com",
"to": "XX@XX.com",
"subject": "{{ctx.payload.aggregations.distinct_watches.buckets}} ",
"body": "{{ctx.payload.aggregations.distinct_watches.buckets.0.key}}"
}
}
}
}
The results of the code I have in the "subject" look like this:
{0={key=AcTag-CM-1234, doc_count=24182}, 1={key=AcTag-W-21308, doc_count=15885}, 2={key=AcTag-D-10705, doc_count=15849}, 3={key=AcTag-test, doc_count=5491}, 4={key=AcTag-Test, doc_count=102}, 5={key=AcTag-Test1, doc_count=78}
I'd ideally have an array or list or table that can show these results rather than just this massive ugly text. Is there some way to make this look nicer?
And the results in the body only show one watch and I can't seem to say [0-], [0,] or anything like that to say that I want ALL of the results that I get from the given aggregation.
Any direction is appreciated!