Help in Alert using watcher


(george) #1

Hi,

We are using Watcher component for alerting. We have a use case where we need to check for fault rate for all services every 5 minutes and if the fault rate for any service is greater than threshold we need to fire the action.
Is it possible to use painless script for iterating though the model in action section of the alert.

thanks in advance.


(Alexander Reelsen) #2

can you be more exact what you refer to as the model in action section of the alert? If you mean, you want to iterate through the result set, when sending an email for example, then you would not use painless but mustache for looping through this.

For examples how to do this, check out the Alerting part in our examples repository.


(george) #3

Yes i would like to iterate through the result set and send specific values that satisfies the condition as part of the alert, Can you please point me to an example where we are iterating through the result set using mustache or any other way in the action section of the alert.


(rich collier) #4

Please see: https://github.com/elastic/examples/blob/master/Alerting/Sample%20Watches/filesystem_usage/watch.json

  "actions": {
    "log": {
      "logging": {
        "text": {
          "inline": "Some hosts are over {{ctx.payload.threshold}}% utilized:{{#ctx.payload.hosts}}{{disk_usage}}%-{{key}}:{{/ctx.payload.hosts}}"
        }
      }
    }
  }

(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.