Hi All,
I have been trying for nearly 4 hours already to get an email alert with data table using Watcher, despite receiving the email it fails to send the data using the _source fields specified. My Watcher alert is as below:
{
"trigger": {
"schedule": {
"interval": "2m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"logstash-*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-5m"
}
}
}
],
"must_not": [
{
"match": {
"response": 200
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gte": 1
}
}
},
"actions": {
"send_email": {
"email": {
"profile": "standard",
"to": [
"xxxxxx@xxxxx.com"
],
"subject": "TEST Watcher Notification",
"body": {
"html": "There is a total of {{ctx.payload.hits.total}} errors so far in the last 5 minutes.<br><br><strong>Snapshot of errors:</strong><br><br><table><tr><th>Timestamp</th> <th>Client_IP</th> <th>Response_Code</th></tr>{{#ctx.payload.hits.hits}}<tr><td>{{_source.timestamp}}</td> <td>{{_source.clientip}}</td><td>{{_source.response}}</td>{{/ctx.payload.hits.hits}}</table><br><br>"
}
}
}
}
}
When the email is triggered, I get the below email but with no data.
A sample document is as below:
{
"host" : "elastic",
"message" : "92.115.179.247 - - [20/May/2015:21:05:35 +0000] \"GET /favicon.ico HTTP/1.1\" 304 3638 \"-\" \"Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0\"",
"auth" : "-",
"ident" : "-",
"httpversion" : "1.1",
"verb" : "GET",
"path" : "/var/log/test.log",
"clientip" : "92.115.179.247",
"@version" : "1",
"request" : "/favicon.ico",
"response" : "304",
"@timestamp" : "2021-04-12T15:51:32.357Z",
"bytes" : "3638",
"timestamp" : "20/May/2015:21:05:35 +0000"
}
I am not sure what I am missing here and even after such a long stretch I am unable to make it work
Kindly help!
Thanks,
Arun