The output of an aggregation in search (or in watcher), currently comes as JSON and contains key-value. The outcome is different and may contain different fields, so hardcoding them into an html body is not possible. Is there a way I can make the output of WATCHER into an html table (action of email) automatically?
For example
{
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-3h"
}
}
},
{
"match": {
"event.dataset": "sample_web_logs"
}
}
]
}
},
"aggs": {
"group_by_src": {
"terms": {
"field": "geo.src",
"size": 2
},
"aggs": {
"group_by_dest": {
"terms": {
"field": "geo.dest",
"size": 2
}
}
}
}
}
}
The data output is
{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 7824,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"group_by_src" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 5086,
"buckets" : [
{
"key" : "CN",
"doc_count" : 1379,
"group_by_dest" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 921,
"buckets" : [
{
"key" : "CN",
"doc_count" : 246
},
{
"key" : "IN",
"doc_count" : 212
}
]
}
},
{
"key" : "IN",
"doc_count" : 1359,
"group_by_dest" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 827,
"buckets" : [
{
"key" : "IN",
"doc_count" : 307
},
{
"key" : "CN",
"doc_count" : 225
}
]
}
}
]
}
}
}
I needed the output in the email
to be an html table without individually picking up the key-value into a hard-coded html