diff --git a/docs/filters.rst b/docs/filters.rst index 2ad7c8ce..d8010c20 100644 --- a/docs/filters.rst +++ b/docs/filters.rst @@ -22,6 +22,9 @@ Event Filters - Include and exclude keys from the event object * - dashes_to_underscores - This filter changes the dashes in all keys in the payload to be underscore. + * - insert_hosts_to_meta + - This filter inserts the hosts from the event into the meta key within the event + based on a custom path in the event object. | Events filters can be chained one after the other, and the updated data is | sent from one filter to the next. @@ -30,7 +33,7 @@ Event Filters | When the rulebook starts the Source plugin it associates the correct filters | and transforms the data before putting it into the queue. -e.g. +Examples: .. code-block:: yaml diff --git a/docs/host_limit.rst b/docs/host_limit.rst index 95c14be7..6ef5670b 100644 --- a/docs/host_limit.rst +++ b/docs/host_limit.rst @@ -17,3 +17,31 @@ Event data example: The value for "hosts" can be a comma delimited string of multiple host names, but typically it is a single host. This is useful to restrict a remedy playbook to run only on the problematical host that emits a monitored event. Be sure that the source plugin already sends this metadata. + + +Inserting hosts to meta +----------------------- + +The plugins may not send metadata like for example the `ansible.eda.webhook` plugin which +sends the arbitrary payload under the `payload` key. + +To accommodate this, the EDA collection provides the `insert_hosts_to_meta` filter, +allowing any plugin to customize the value of `event.meta.hosts` based on the contents +of a specific key in the event. + +.. note:: + + The host_path argument in the filter `insert_hosts_to_meta` does not need the `event.` prefix + like conditions or action arguments. + + +Example: + +.. code-block:: yaml + + sources: + - ansible.eda.webhook: + port: 4444 + filters: + - ansible.eda.insert_hosts_to_meta: + host_path: "payload.alert.instances"