Query parameters

  • debugboolean

    Defines whether the watch runs in debug mode.

application/json

Body

  • Determines how to handle the watch actions as part of the watch execution.

    Hide action_modes attribute Show action_modes attribute object
    • *string Additional properties

      Values are simulate, force_simulate, execute, force_execute, or skip.

  • When present, the watch uses this object as a payload instead of executing its own input.

    Hide alternative_input attribute Show alternative_input attribute object
    • *object Additional properties
  • When set to true, the watch execution uses the always condition. This can also be specified as an HTTP parameter.

  • When set to true, the watch record representing the watch execution result is persisted to the .watcher-history index for the current time. In addition, the status of the watch is updated, possibly throttling subsequent runs. This can also be specified as an HTTP parameter.

  • Hide simulated_actions attributes Show simulated_actions attributes object
  • Hide trigger_data attributes Show trigger_data attributes object
    • scheduled_timestring | number Required

      A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

      One of:

      Time unit for milliseconds

    • triggered_timestring | number

      A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

      One of:

      Time unit for milliseconds

  • watchobject
    Hide watch attributes Show watch attributes object
    • actionsobject Required
      Hide actions attribute Show actions attribute object
      • *object Additional properties
        Hide * attributes Show * attributes object
        • Values are email, webhook, index, logging, slack, or pagerduty.

        • conditionobject
          Hide condition attributes Show condition attributes object
          • alwaysobject
          • Hide array_compare attribute Show array_compare attribute object
            • *object Additional properties
              Hide * attribute Show * attribute object
          • compareobject
            Hide compare attribute Show compare attribute object
            • *object Additional properties
          • neverobject
          • scriptobject
            Hide script attributes Show script attributes object
            • langstring
            • paramsobject
              Hide params attribute Show params attribute object
              • *object Additional properties
            • sourcestring
            • idstring
        • foreachstring
        • namestring
        • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

        • Time unit for milliseconds

        • transformobject
          Hide transform attributes Show transform attributes object
          • chainarray[object]
          • scriptobject
            Hide script attributes Show script attributes object
            • langstring
            • paramsobject
              Hide params attribute Show params attribute object
              • *object Additional properties
            • sourcestring
            • idstring
        • indexobject
          Hide index attributes Show index attributes object
          • indexstring Required
          • doc_idstring
          • refreshstring

            Values are true, false, or wait_for.

          • op_typestring

            Values are index or create.

          • timeoutstring

            A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

          • Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

        • loggingobject
          Hide logging attributes Show logging attributes object
        • emailobject
          Hide email attributes Show email attributes object
        • pagerdutyobject
          Hide pagerduty attributes Show pagerduty attributes object
        • slackobject
          Hide slack attributes Show slack attributes object
        • webhookobject
          Hide webhook attributes Show webhook attributes object
          • authobject
            Hide auth attribute Show auth attribute object
          • bodystring
          • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

          • headersobject
            Hide headers attribute Show headers attribute object
          • hoststring
          • methodstring

            Values are head, get, post, put, or delete.

          • paramsobject
            Hide params attribute Show params attribute object
            • *string Additional properties
          • pathstring
          • portnumber
          • proxyobject
            Hide proxy attributes Show proxy attributes object
          • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

          • schemestring

            Values are http or https.

          • urlstring
    • conditionobject Required
      Hide condition attributes Show condition attributes object
      • alwaysobject
      • Hide array_compare attribute Show array_compare attribute object
        • *object Additional properties
          Hide * attribute Show * attribute object
      • compareobject
        Hide compare attribute Show compare attribute object
        • *object Additional properties
      • neverobject
      • scriptobject
        Hide script attributes Show script attributes object
        • langstring
        • paramsobject
          Hide params attribute Show params attribute object
          • *object Additional properties
        • sourcestring
        • idstring
    • inputobject Required
      Hide input attributes Show input attributes object
      • chainobject
        Hide chain attribute Show chain attribute object
        • inputsarray[object] Required
          Hide inputs attribute Show inputs attribute object
          • *object
      • httpobject
        Hide http attributes Show http attributes object
        • extractarray[string]
        • requestobject
          Hide request attributes Show request attributes object
          • authobject
            Hide auth attribute Show auth attribute object
            • basicobject Required
              Hide basic attributes Show basic attributes object
          • bodystring
          • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

          • headersobject
            Hide headers attribute Show headers attribute object
          • hoststring
          • methodstring

            Values are head, get, post, put, or delete.

          • paramsobject
            Hide params attribute Show params attribute object
            • *string Additional properties
          • pathstring
          • portnumber
          • proxyobject
            Hide proxy attributes Show proxy attributes object
          • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

          • schemestring

            Values are http or https.

          • urlstring
        • Values are json, yaml, or text.

      • simpleobject
        Hide simple attribute Show simple attribute object
        • *object Additional properties
    • metadataobject
      Hide metadata attribute Show metadata attribute object
    • statusobject
      Hide status attributes Show status attributes object
      • actionsobject Required
        Hide actions attribute Show actions attribute object
      • last_checkedstring | number

        A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

        One of:

        Time unit for milliseconds

      • last_met_conditionstring | number

        A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

        One of:

        Time unit for milliseconds

      • stateobject Required
        Hide state attributes Show state attributes object
        • activeboolean Required
        • timestampstring | number Required

          A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

          One of:

          Time unit for milliseconds

      • versionnumber Required
    • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

    • Time unit for milliseconds

    • transformobject
      Hide transform attributes Show transform attributes object
      • chainarray[object]
      • scriptobject
        Hide script attributes Show script attributes object
        • langstring
        • paramsobject
          Hide params attribute Show params attribute object
          • *object Additional properties
        • sourcestring
        • idstring
    • triggerobject Required
      Hide trigger attribute Show trigger attribute object
      • scheduleobject
        Hide schedule attributes Show schedule attributes object
        • timezonestring
        • cronstring
        • dailyobject
          Hide daily attribute Show daily attribute object
          • atarray[string | object] Required

            A time of day, expressed either as hh:mm, noon, midnight, or an hour/minutes structure.

            A time of day, expressed either as hh:mm, noon, midnight, or an hour/minutes structure.

        • hourlyobject
          Hide hourly attribute Show hourly attribute object
        • intervalstring

          A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

        • monthlyobject | array[object]

          One of:
          Hide attributes Show attributes object
          • atarray[string] Required
          • onarray[number] Required
        • weeklyobject | array[object]

          One of:
          Hide attributes Show attributes object
          • atarray[string] Required
          • onarray[string] Required

            Values are sunday, monday, tuesday, wednesday, thursday, friday, or saturday.

        • yearlyobject | array[object]

          One of:
          Hide attributes Show attributes object
          • atarray[string] Required
          • intarray[string] Required

            Values are january, february, march, april, may, june, july, august, september, october, november, or december.

          • onarray[number] Required

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • _idstring Required
    • watch_recordobject Required
      Hide watch_record attributes Show watch_record attributes object
      • conditionobject Required
        Hide condition attributes Show condition attributes object
        • alwaysobject
        • Hide array_compare attribute Show array_compare attribute object
          • *object Additional properties
            Hide * attribute Show * attribute object
        • compareobject
          Hide compare attribute Show compare attribute object
          • *object Additional properties
        • neverobject
        • scriptobject
          Hide script attributes Show script attributes object
          • langstring
          • paramsobject
            Hide params attribute Show params attribute object
            • *object Additional properties
          • sourcestring
          • idstring
      • inputobject Required
        Hide input attributes Show input attributes object
        • chainobject
          Hide chain attribute Show chain attribute object
          • inputsarray[object] Required
            Hide inputs attribute Show inputs attribute object
            • *object
        • httpobject
          Hide http attributes Show http attributes object
          • extractarray[string]
          • requestobject
            Hide request attributes Show request attributes object
            • authobject
              Hide auth attribute Show auth attribute object
            • bodystring
            • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

            • headersobject
              Hide headers attribute Show headers attribute object
            • hoststring
            • methodstring

              Values are head, get, post, put, or delete.

            • paramsobject
              Hide params attribute Show params attribute object
              • *string Additional properties
            • pathstring
            • portnumber
            • proxyobject
              Hide proxy attributes Show proxy attributes object
            • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

            • schemestring

              Values are http or https.

            • urlstring
          • Values are json, yaml, or text.

        • simpleobject
          Hide simple attribute Show simple attribute object
          • *object Additional properties
      • messagesarray[string] Required
      • metadataobject
        Hide metadata attribute Show metadata attribute object
      • nodestring Required
      • resultobject Required
        Hide result attributes Show result attributes object
        • actionsarray[object] Required
          Hide actions attributes Show actions attributes object
          • emailobject
            Hide email attributes Show email attributes object
          • idstring Required
          • indexobject
            Hide index attribute Show index attribute object
          • loggingobject
            Hide logging attribute Show logging attribute object
          • pagerdutyobject
            Hide pagerduty attributes Show pagerduty attributes object
          • reasonstring
          • slackobject
            Hide slack attributes Show slack attributes object
          • statusstring Required

            Values are success, failure, simulated, or throttled.

          • typestring Required

            Values are email, webhook, index, logging, slack, or pagerduty.

          • webhookobject
            Hide webhook attributes Show webhook attributes object
          • errorobject
            Hide error attributes Show error attributes object
            • typestring Required

              The type of error

            • reasonstring

              A human-readable explanation of the error, in English.

            • The server stack trace. Present only if the error_trace=true parameter was sent with the request.

            • caused_byobject
            • root_causearray[object]
            • suppressedarray[object]
        • conditionobject Required
          Hide condition attributes Show condition attributes object
          • metboolean Required
          • statusstring Required

            Values are success, failure, simulated, or throttled.

          • typestring Required

            Values are always, never, script, compare, or array_compare.

        • Time unit for milliseconds

        • execution_timestring | number Required

          A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

          One of:

          Time unit for milliseconds

        • inputobject Required
          Hide input attributes Show input attributes object
          • payloadobject Required
            Hide payload attribute Show payload attribute object
          • statusstring Required

            Values are success, failure, simulated, or throttled.

          • typestring Required

            Values are http, search, or simple.

      • statestring Required

        Values are awaits_execution, checking, execution_not_needed, throttled, executed, failed, deleted_while_queued, or not_executed_already_queued.

      • trigger_eventobject Required
        Hide trigger_event attributes Show trigger_event attributes object
        • manualobject Required
          Hide manual attribute Show manual attribute object
        • triggered_timestring | number Required

          A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

          One of:

          Time unit for milliseconds

        • typestring Required
      • userstring Required
      • watch_idstring Required
      • statusobject
        Hide status attributes Show status attributes object
        • actionsobject Required
          Hide actions attribute Show actions attribute object
        • last_checkedstring | number

          A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

          One of:

          Time unit for milliseconds

        • last_met_conditionstring | number

          A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

          One of:

          Time unit for milliseconds

        • stateobject Required
          Hide state attributes Show state attributes object
          • activeboolean Required
          • timestampstring | number Required

            A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

            One of:

            Time unit for milliseconds

        • versionnumber Required
POST /_watcher/watch/_execute
curl \
 --request POST 'http://api.example.com/_watcher/watch/_execute' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"trigger_data\" : { \n    \"triggered_time\" : \"now\",\n    \"scheduled_time\" : \"now\"\n  },\n  \"alternative_input\" : { \n    \"foo\" : \"bar\"\n  },\n  \"ignore_condition\" : true, \n  \"action_modes\" : {\n    \"my-action\" : \"force_simulate\" \n  },\n  \"record_execution\" : true \n}"'
Run `POST _watcher/watch/my_watch/_execute` to run a watch. The input defined in the watch is ignored and the `alternative_input` is used as the payload. The condition as defined by the watch is ignored and is assumed to evaluate to true. The `force_simulate` action forces the simulation of `my-action`. Forcing the simulation means that throttling is ignored and the watch is simulated by Watcher instead of being run normally.
{
  "trigger_data" : { 
    "triggered_time" : "now",
    "scheduled_time" : "now"
  },
  "alternative_input" : { 
    "foo" : "bar"
  },
  "ignore_condition" : true, 
  "action_modes" : {
    "my-action" : "force_simulate" 
  },
  "record_execution" : true 
}
Run `POST _watcher/watch/my_watch/_execute` and set a different mode for each action.
{
  "action_modes" : {
    "action1" : "force_simulate",
    "action2" : "skip"
  }
}
Run `POST _watcher/watch/_execute` to run a watch inline. All other settings for this API still apply when inlining a watch. In this example, while the inline watch defines a compare condition, during the execution this condition will be ignored.
{
  "watch" : {
    "trigger" : { "schedule" : { "interval" : "10s" } },
    "input" : {
      "search" : {
        "request" : {
          "indices" : [ "logs" ],
          "body" : {
            "query" : {
              "match" : { "message": "error" }
            }
          }
        }
      }
    },
    "condition" : {
      "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
    },
    "actions" : {
      "log_error" : {
        "logging" : {
          "text" : "Found {{ctx.payload.hits.total}} errors in the logs"
        }
      }
    }
  }
}
Response examples (200)
A successful response from `POST _watcher/watch/my_watch/_execute`.
{
  "_id": "my_watch_0-2015-06-02T23:17:55.124Z", 
  "watch_record": { 
    "@timestamp": "2015-06-02T23:17:55.124Z",
    "watch_id": "my_watch",
    "node": "my_node",
    "messages": [],
    "trigger_event": {
      "type": "manual",
      "triggered_time": "2015-06-02T23:17:55.124Z",
      "manual": {
        "schedule": {
          "scheduled_time": "2015-06-02T23:17:55.124Z"
        }
      }
    },
    "state": "executed",
    "status": {
      "version": 1,
      "execution_state": "executed",
      "state": {
        "active": true,
        "timestamp": "2015-06-02T23:17:55.111Z"
      },
      "last_checked": "2015-06-02T23:17:55.124Z",
      "last_met_condition": "2015-06-02T23:17:55.124Z",
      "actions": {
        "test_index": {
          "ack": {
            "timestamp": "2015-06-02T23:17:55.124Z",
            "state": "ackable"
          },
          "last_execution": {
            "timestamp": "2015-06-02T23:17:55.124Z",
            "successful": true
          },
          "last_successful_execution": {
            "timestamp": "2015-06-02T23:17:55.124Z",
            "successful": true
          }
        }
      }
    },
    "input": {
      "simple": {
        "payload": {
          "send": "yes"
        }
      }
    },
    "condition": {
      "always": {}
    },
    "result": { 
      "execution_time": "2015-06-02T23:17:55.124Z",
      "execution_duration": 12608,
      "input": {
        "type": "simple",
        "payload": {
          "foo": "bar"
        },
        "status": "success"
      },
      "condition": {
        "type": "always",
        "met": true,
        "status": "success"
      },
      "actions": [
        {
          "id": "test_index",
          "index": {
            "response": {
              "index": "test",
              "version": 1,
              "created": true,
              "result": "created",
              "id": "AVSHKzPa9zx62AzUzFXY"
            }
          },
          "status": "success",
          "type": "index"
        }
      ]
    },
    "user": "test_admin" 
  }
}