File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/__pycache__/fluent.cpython-310.pyc
o
�N�g � @ sd d Z ddlZddlZz
ddlmZmZ W n ey dZY nw e�e �Z
dZdd� Zdd
d�Z
dS )
a�
An engine that reads messages from the salt event bus and pushes
them onto a fluent endpoint.
.. versionadded:: 3000
:Configuration:
All arguments are optional
Example configuration of default settings
.. code-block:: yaml
engines:
- fluent:
host: localhost
port: 24224
app: engine
Example fluentd configuration
.. code-block:: none
<source>
@type forward
port 24224
</source>
<match saltstack.**>
@type file
path /var/log/td-agent/saltstack
</match>
:depends: fluent-logger
� N)�event�sender�fluentc C s t d urtS dS )N)Fzfluent-logger not installed)r �__virtualname__� r r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/fluent.py�__virtual__4 s
���r � localhost�^ �enginec C s� d}t j|| |d� t�d��d�rtjjjttd dd�}n
tjjj dttd dd �}t
�d
� |� |�� }|rAt�
||� q51 sEw Y dS )ao
Listen to salt events and forward them to fluent
args:
host (str): Host running fluentd agent. Default is localhost
port (int): Port of fluentd agent. Default is 24224
app (str): Text sent as fluentd tag. Default is "engine". This text is appended
to "saltstack." to form a fluentd tag, ex: "saltstack.engine"
� saltstack)�host�port�idZ_master�sock_dirT)�listenZminion)�optsr r zFluent engine startedN)r �setupZ__opts__�get�endswith�salt�utilsr Zget_master_eventZ get_event�log�infoZget_event_block�Event)r
r ZappZSENDER_NAMEZ event_busZ
salt_eventr r r �start<