Hi,
Be indulgent plz this is my first watcher
I'm trying to create a watcher in where I can:
- call and fetch a filter/report for a specific index (stream).
The idea is to catch from received logs, of a specific duration, all the errors and send for eachone an alert by email.
I started with this example but I'm sure it's not complete:
''''
{
"trigger": {
"schedule": {
"interval": "15m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"Test_Watcher_URL_Filter"
],
"rest_total_hits_as_int": true,
"body": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "error OR loglevel:ERROR"
}
},
{
"range": {
"@timestamp": {
"lte": "now-7h"
}
}
}
]
}
},
"_source": [
"message"
],
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"send_email": {
"foreach": "ctx.payload.hits.hits",
"max_iterations": 100,
"email": {
"profile": "standard",
"to": [
"receiver@servermail.com"
],
"subject": "Watcher Notification - Error received ",
"body": {
"text": " Errors have occured in the logs: ['message'].value"
}
}
}
},
"throttle_period_in_millis": 900000
}
'''
Can you please help me to achieve this watcher creation.
Regards