Hello,
I have created the following watcher alert:
{
"trigger": {
"schedule": {
"hourly": {
"minute": [
1,
3,
11,
16,
23,
31,
41,
51
]
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"simulation-connect"
],
"rest_total_hits_as_int": true,
"body": {
"query": {
"bool": {
"must": [
{
"match_phrase": {
"customerNr_onBehalf": {
"query": "1234"
}
}
},
{
"range": {
"@timestamp": {
"gte": "now-50m"
}
}
}
],
"filter": [
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"match": {
"resultAddArticleToBasket": true
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"match": {
"resultArticleSearch": true
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"match": {
"resultFullTextSearch": true
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"match": {
"resultLogout": true
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"match": {
"resultLogin": true
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"match": {
"resultVehicleSearch": true
}
}
],
"minimum_should_match": 1
}
}
],
"minimum_should_match": 1
}
}
],
"minimum_should_match": 1
}
}
],
"minimum_should_match": 1
}
}
],
"minimum_should_match": 1
}
}
],
"minimum_should_match": 1
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gte": "1"
}
}
},
"actions": {
"send_email": {
"email": {
"profile": "standard",
"to": [
"alexandros.ananikidis@sag-ag.ch"
],
"subject": "[CH PROD] Connect CH Customer Simulation Failed",
"body": {
"text": "Elastic results are the following: {{#ctx.payload.hits.hits}}{{_source}}{{/ctx.payload.hits.hits}}"
}
}
}
}
}
And the output is correctly like that:
Nevertheless, because as anyone can imagine it is extremely inconvenient to read how can i change the code in my alert so i can have at the end an email notification that will show the info in a more easy and clear way to read?
For example like that:
The results are the following:
Hit 1
resultLogin=true,
@timestamp=1586857855,
resultVehicleSearch=true,
resultArticleSearch=true,
resultFullTextSearch=true,
sessionID=455108a4054a4c2a93fa23cba4bc85c4,
customerNr_onBehalf=1234,
resultAddArticleToBasket=true,
resultLogout=true
Hit 2
resultLogin=true
@timestamp=1586858457,
resultVehicleSearch=true,
resultArticleSearch=true,
resultFullTextSearch=true,
sessionID=63c8aebbd39842398afa7b7399025526,
customerNr_onBehalf=1234,
resultAddArticleToBasket=true,
resultLogout=true
Hit 3....and so on