condition.asciidoc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. [[condition]]
  2. == Conditions
  3. When a watch is triggered, its condition determines whether or not to execute
  4. the watch actions. {watcher} supports the following condition types:
  5. * <<condition-always, `always`>>: set the watch condition to `true` so the watch
  6. actions are always executed.
  7. * <<condition-never, `never`>>: set the watch condition to `false` so the watch
  8. actions are never executed.
  9. * <<condition-compare, `compare`>>: perform simple comparisons against values
  10. in the watch payload to determine whether or not to execute the watch actions.
  11. * <<condition-array-compare, `array_compare`>>: compare an array of values in the
  12. watch payload to a given value to determine whether or not to execute the watch
  13. actions.
  14. * <<condition-script, `script`>>: use a script to determine whether or not to
  15. execute the watch actions.
  16. NOTE: If you omit the condition definition from a watch, the condition defaults
  17. to `always`.
  18. When a condition is evaluated, it has full access to the watch execution context,
  19. including the watch payload (`ctx.payload.*`). The <<condition-script, script>>,
  20. <<condition-compare, compare>> and <<condition-array-compare, array_compare>>
  21. conditions can use the payload data to determine whether or not the necessary
  22. conditions are met.
  23. In addition to the watch wide condition, you can also configure conditions
  24. per <<action-conditions, action>>.
  25. :edit_url: https://github.com/elastic/elasticsearch/edit/{branch}/x-pack/docs/en/watcher/condition/always.asciidoc
  26. include::condition/always.asciidoc[]
  27. :edit_url: https://github.com/elastic/elasticsearch/edit/{branch}/x-pack/docs/en/watcher/condition/never.asciidoc
  28. include::condition/never.asciidoc[]
  29. :edit_url: https://github.com/elastic/elasticsearch/edit/{branch}/x-pack/docs/en/watcher/condition/compare.asciidoc
  30. include::condition/compare.asciidoc[]
  31. :edit_url: https://github.com/elastic/elasticsearch/edit/{branch}/x-pack/docs/en/watcher/condition/array-compare.asciidoc
  32. include::condition/array-compare.asciidoc[]
  33. :edit_url: https://github.com/elastic/elasticsearch/edit/{branch}/x-pack/docs/en/watcher/condition/script.asciidoc
  34. include::condition/script.asciidoc[]