# After match, get next lines in a watcher alert

**URL:** <https://discuss.elastic.co/t/after-match-get-next-lines-in-a-watcher-alert/303583>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [April 29, 2022, 8:23am UTC](https://discuss.elastic.co/t/after-match-get-next-lines-in-a-watcher-alert/303583 "2022-04-29T08:23:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sree3](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sree3](https://discuss.elastic.co/u/sree3)\
**Post date:** [April 29, 2022, 8:23am UTC](https://discuss.elastic.co/t/after-match-get-next-lines-in-a-watcher-alert/303583/1 "2022-04-29T08:23:12Z")

</div>

Hi All,

I have configured a watcher alert that will search a particular query pattern. This is working fine and what i'm trying to achieve is to get the next 4 lines also added to notifications, if the above match is found. Currently we are getting only exact match line in the alert.

Could someone please help on this.

```auto
{
  "trigger": {
    "schedule": {
      "interval": "2m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "applications-*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": 1,
          "query": {
            "bool": {
              "must": [
                {
                  "match": {
                    "message": {
                      "query": "[message]",
                      "operator": "and"
                    }
                  }
                },
                {
                  "range": {
                    "@timestamp": {
                      "gte": "now-3m"
                    }
                  }
                }
              ]
            }
          },
          "_source": [
            "message",
            "beat.name",
            "@timestamp"
          ]
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gt": 0
      }
    }
  },
  "actions": {
    "email_me": {
      "email": {
        "profile": "standard",
        "priority": "high",
        "to": [
          "test@test.com"
        ],
        "subject": "Test [Message)]",
        "body": {
          "text": "Message = Test {{ctx.payload.hits.hits.0._source.message}} - {{ctx.payload.hits.hits.0._source.@timestamp}} ] - Please review }"
        }
      }
    }
  },
  "metadata": {
    "color": "red"
  },
  "throttle_period_in_millis": 900000
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 27, 2022, 8:23am UTC](https://discuss.elastic.co/t/after-match-get-next-lines-in-a-watcher-alert/303583/2 "2022-05-27T08:23:42Z")

</div>

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