# Watcher executes action only for 10 times

**URL:** https://discuss.elastic.co/t/watcher-executes-action-only-for-10-times/226350
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [April 3, 2020, 7:21am UTC](https://discuss.elastic.co/t/watcher-executes-action-only-for-10-times/226350 "2020-04-03T07:21:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Donatas\_Racys](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/donatas_racys/32/48742_2.png) [@Donatas\_Racys](https://discuss.elastic.co/u/Donatas_Racys)
#### Post date: [April 3, 2020, 7:21am UTC](https://discuss.elastic.co/t/watcher-executes-action-only-for-10-times/226350/1 "2020-04-03T07:21:05Z")

</div>

Hi folks, we have an case - Watcher performs Pagerduty/webhook action" only 10 times per trigger interval. We use foreach iteration in action and we receive only 10 notifications in Pagerduty.

This is visible in Watcher simulation log - **number\_of\_actions\_executed": 10**

```auto
    "condition": {
      "type": "compare",
      "status": "success",
      "met": true,
      "compare": {
        "resolved_values": {
          "ctx.payload.hits.total": 78
        }
      }
    },
    "actions": [
      {
        "id": "my_webhook",
        "type": "webhook",
        "status": "simulated",
        "number_of_actions_executed": 10,

```

Watcher configuration:

```auto
{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "prod-logs-*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "bool": {
              "must": [
                {
                  "query_string": {
                    "query": "log_level:ERROR AND (environment:prod AND arena:playlive)"
                  }
                },
                {
                  "range": {
                    "@timestamp": {
                      "gte": "now-15m"
                    }
                  }
                }
              ]
            }
          },
          "sort": [
            {
              "@timestamp": {
                "order": "desc"
              }
            }
          ]
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gt": 0
      }
    }
  },
  "actions": {
    "my_webhook": {
      "foreach": "ctx.payload.hits.hits",
      "max_iterations": 100,
      "webhook": {
        "scheme": "http",
        "host": "10.10.10.222",
        "port": 31311,
        "method": "post",
        "params": {},
        "headers": {},
        "body": "{{#toJson}}ctx.payload{{/toJson}}"
      }
    }
  }
}

```

How can we increase this number to unlimited, because we want to have all events sent from Watcher - not only first 10.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [April 3, 2020, 1:36pm UTC](https://discuss.elastic.co/t/watcher-executes-action-only-for-10-times/226350/2 "2020-04-03T13:36:09Z")

</div>

Unless specified differently in the search request, a search response will only contain 10 hits including their `_source` regardless of the number of results.

See [https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#request-body-search-from-size](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#request-body-search-from-size)

---

<div class="post-metadata">

### Author: ![Donatas\_Racys](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/donatas_racys/32/48742_2.png) [@Donatas\_Racys](https://discuss.elastic.co/u/Donatas_Racys)
#### Post date: [April 6, 2020, 7:35am UTC](https://discuss.elastic.co/t/watcher-executes-action-only-for-10-times/226350/3 "2020-04-06T07:35:08Z")

</div>

Thanks a lot ! You saved my day 🙂

---

<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 4, 2020, 7:35am UTC](https://discuss.elastic.co/t/watcher-executes-action-only-for-10-times/226350/4 "2020-05-04T07:35:25Z")

</div>

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