Hi, I'm trying to write a watcher for two specific hosts, for when we do not receive a log entry for them. I found a previous post looking for similar, which linked to this example. I've been trying to modify this to look for specific hostnames, with "MOL" in the name.
However it fails to trigger with error "failed to execute watch input". Modified code below.
{
"metadata": {
"window_period": "1h",
"last_period":"8m"
},
"trigger": {
"schedule": {
"interval": "3m"
}
},
"input": {
"search": {
"request": {
"indices": [
"perf-metrics-*"
],
"types": [],
"body": {
"query": {
"@timestamp": {
"gte": "now-{{ctx.metadata.window_period}}"
}
},
"aggs": {
"periods": {
"filters": {
"filters": {
"history": {
"range": {
"@timestamp": {
"gte": "now-{{ctx.metadata.window_period}}"
}
}
},
"last_period": {
"range": {
"@timestamp": {
"gte": "now-{{ctx.metadata.last_period}}"
}
}
},
"match": {
"host": "*MOL*"
}
}
},
"aggs": {
"hosts": {
"terms": {
"field": "host",
"size": 10000
}
}
}
}
},
"size": 0
}
}
}
},
"condition": {
"script": {
"id": "condition"
}
},
"actions": {
"script": {
"lang": "painless",
"source": "return ctx.payload.aggregations.periods.buckets.history.hosts.buckets.size() > ctx.payload.aggregations.periods.buckets.last_period.hosts.buckets.size();"
}
}