Hi,
I have setup heartbeat and monitoring URLs.
I need help setting up when the URL goes down, I want to send only 1 email with the body of "URL goes down".
If any of the URL comes back up, I want to send only 1 email with the body of "The URL is back up".
I have set up for the down alert which works for me. But I need to set up for the up alert. I have used the throttle period field to repeat the alert for next trigger. But I cannot use the same way in up alert configuration.
Can someone please assist? I have tried and looked everywhere, cannot find correct configuration.
Down alert Config:
{
"trigger": {
"schedule": {
"interval": "10m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"heartbeat*"
],
"rest_total_hits_as_int": true,
"body": {
"_source": [
"monitor.id",
"url.full",
"summary.down",
"lacode",
"monitor.name"
],
"query": {
"bool": {
"must": [
{
"match": {
"summary.down": 1
}
},
{
"terms": {
"lacode": [
"LA001697"
]
}
}
],
"filter": [
{
"term": {
"monitor.type": "http"
}
},
{
"term": {
"summary.down": 1
}
},
{
"range": {
"@timestamp": {
"gte": "now-30m"
}
}
}
]
}
},
"aggs": {
"monitorId": {
"terms": {
"field": "monitor.id",
"size": 10000
},
"aggs": {
"types_count": {
"value_count": {
"field": "monitor.id"
}
},
"lacode_bucket_filter": {
"bucket_selector": {
"buckets_path": {
"valueCount": "types_count"
},
"script": "params.valueCount > 3"
}
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "return ctx.payload.aggregations.monitorId.buckets.size() > 0",
"lang": "painless"
}
},
"actions": {
"send_email": {
"email": {
"profile": "standard",
"to": [
"nandhiniravisankar1999@gmail.com"
],
"subject": "URLs are down and their code {{ctx.payload._value.2}}, {{ctx.payload._value.3}}",
"body": {
"html": "The number of URLs are down: {{ctx.payload._value.1}} <br><br>{{ctx.payload._value.0}}"
}
}
}
},
"transform": {
"script": {
"source": """
Set set = ctx.payload.aggregations.monitorId.buckets.stream().map( it -> it.key).collect(Collectors.toSet());
return [
String.join("<br /> ",ctx.payload.hits.hits.stream()
.filter( k -> set.contains( k._source.monitor.id))
.map(p -> p._source.url.full)
.collect(Collectors.toSet()))
,
set.size(),
String.join("<br /> ",ctx.payload.hits.hits.stream()
.filter( k -> set.contains( k._source.monitor.id))
.map(p -> p._source.lacode)
.collect(Collectors.toSet())),
String.join("<br /> ",ctx.payload.hits.hits.stream()
.filter( k -> set.contains( k._source.monitor.id))
.map(p -> p._source.monitor.name)
.collect(Collectors.toSet()))
]
""",
"lang": "painless"
}
},
"throttle_period_in_millis": 54000000
}
Please suggest some solution for this.
Thank you!!