Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add 'inserting hosts' section in docs #660

Merged
merged 8 commits into from
Mar 13, 2024
5 changes: 4 additions & 1 deletion docs/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
28 changes: 28 additions & 0 deletions docs/host_limit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Alex-Izquierdo marked this conversation as resolved.
Show resolved Hide resolved

sources:
- ansible.eda.webhook:
port: 4444
filters:
- ansible.eda.insert_hosts_to_meta:
host_path: "payload.alert.instances"
Loading