Hi,
We use a large number of watchers to monitor the health of our VMs and services (RAM usage, failed services, etc.). Unfortunately, it's extremely prone to false-negatives; we often have problems that are ongoing but aren't detected by email-alerts, which from our perspective looks like there's no problem.
I want to test our email-alerting with data that will definitively trigger an email-alert to make our watchers more reliable.
For example, the following watcher is triggered if less than 90 heartbeat-messages are seen in heartbeat-*
within the last ten minutes. I'd like to test this watcher over REST with a manually-provided search_match result (an empty array), and then check that the watcher was triggered from the response body.
If I can do this, I can build a test-suite for our watchers easily.
I think the Execute API supports this, but I don't really understand exactly what the parameter documentation for trigger-data
or alternative_input
meant, or how these parameters differ.
- Can
trigger-data
oralternative_input
be used to provide fake input data to a watcher? What would this data be in the case of providing empty search results? - How do the
trigger_data
andalternative_input
parameters differ? - Is there a 'canonical' way of testing watchers that I missed?
Any help would be appreciated
Example Watcher
{
"trigger": {
"schedule": {
"interval": "15m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"heartbeat-*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"host": "vm_0"
}
},
{
"match": {
"tags": "heartbeat"
}
},
{
"range": {
"@timestamp": {
"gte": "now-10m"
}
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"lt": 90
}
}
},
"actions": {
"email_administrator": {
"throttle_period": "15m",
"email": {
"profile": "standard",
"attachments": {
"attached_data": {
"data": {
"format": "json"
}
}
},
"priority": "low",
"to": [
"foo@example.com"
],
"subject": "Watcher - too heartbeat messages",
"body": {}
}
}
}
}