Watcher executes action only for 10 times

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

    "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:

{
  "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!

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

Thanks a lot ! You saved my day :slight_smile:

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