{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "metricbeat-*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": 0,
          "query": {
            "bool": {
              "filter": [
                {
                  "bool": {
                    "must": [
                      {
                        "term": {
                          "metricset.name": "uptime"
                        }
                      },
                      {
                        "range": {
                          "@timestamp": {
                            "gte": "now-15m"
                          }
                        }
                      },
                      {
                        "term": {
                          "tags": "192.168.1.34"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      }
    }
  },
  "condition": {
    "script": {
      "source": "return ctx.payload.hits.total < 1",
      "lang": "painless"
    }
  },
  "actions": {
    "my-logging-action": {
      "logging": {
        "level": "info",
        "text": """Alert: {{ctx.payload.result.tags}} Node Down
         Server: {{ctx.payload.result.tags}}
timestamp: {{ctx.payload.result.action_time}}
Severity: High"""
      }
    },
    "email_action": {
      "email": {
        "account": "gmail",
        "profile": "standard",
        "from": "maskerti90@gmail.com",
        "to": [
          "maskerti90@gmail.com"
        ],
        "subject": "{{ctx.payload.result.tags}} Node Down",
        "body": {
          "text": """Alert: {{ctx.payload.result.tags}} Node Down
         Server: {{ctx.payload.result.tags}}
timestamp: {{ctx.payload.result.action_time}}
Severity: High"""
        }
      }
    }
  }
}
Output i am getting on elasticsearch.log
[2022-11-13T15:07:54,781][INFO ][o.e.x.w.a.l.ExecutableLoggingAction] [node-1] Alert:  Node Down
         Server:
timestamp:
Severity: High
[2022-11-13T15:08:54,959][INFO ][o.e.x.w.a.l.ExecutableLoggingAction] [node-1] Alert:  Node Down
         Server:
timestamp:
Severity: High
and on mail i am getting this output
Alert:  Node Down
         Server:
timestamp:
Severity: High
Basically my purpose is to get alert for when node goes , for this i am using metricbeat. I stopped one server to test this . In this query i am not getting node ip is there any way i can get node ip.