How to generate alert for specific host name

Hi,

I want to set a trigger when cpu usage reached more than 90% on beat.hostname is elsearchdv1

below are my watcher.json



{
  "trigger": {
    "schedule": {
      "interval": "1s"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "metricbeat-*"
        ],
        "types": [],
        "body": {
          "query": {
              
            "match": {
              "beat.hostname": "elsearchdv1"
            },
            "range": {
              "system.cpu.user.pct": {
                "gt": "0.90"
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gte": 1
      }
    }
  },
  "actions": {
    "send_email": {
      "email": {
        "profile": "standard",
        "to": [
          "xxx@yyy.com"
        ],
        "subject": "Watcher Notification",
        "body": {
          "text": "CPU Threshold for {{ctx.payload.hits.hits.0._source.host}} exceeded"
        }
      }
    }
  }
}


its not generating an alert please help me in this.

You should use the Threshold alert builder for this. It's in the UI in Kibana, next to the Advanced watch.

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