Guys,
I have looked all over the internet, and i cant seem to get a simple answer at all.
So, we have an watcher configuration which triggers an email when a particular condition is satisfied.
But, it prints only the hits.
Now, can anyone please tell me in simple code, how to print the payload in the email action.
Here is my watcher configuration
{
"trigger": {
"schedule": {
"interval": "30s"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"my-index-*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "system.cpu.total.pct : [0.3 TO *]"
}
},
{
"range": {
"@timestamp": {
"gte": "now-7d"
}
}
}
]
}
},
"_source": [
"message"
],
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gte": 1
}
}
},
"actions": {
"send_email": {
"email": {
"profile": "standard",
"to": [
"myemail@mydomain.com"
],
"subject": "Warning: High CPU Utilization",
"body": {
"text": "{{ctx.payload.hits.total}} Times the CPU Utilization has crossed the threshold value {{#ctx.payload._value}}{{.}}:{{/ctx.payload._value}}"
}
}
}
},
"throttle_period_in_millis": 60000
}
sample_cpu_watcher.json
Displaying sample_cpu_watcher.json.