File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/log_handlers/__pycache__/fluent_mod.cpython-310.pyc
Back
o ;j*B � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl Zddl mZ e�e �ZdZdaddddddd d d�Zdd � Zdd� Zdd� Zdd� ZG dd� dej�ZG dd� dej�ZG dd� d�ZdS )aX Fluent Logging Handler ====================== .. versionadded:: 2015.8.0 This module provides some fluentd_ logging handlers. Fluent Logging Handler ---------------------- In the `fluent` configuration file: .. code-block:: text <source> type forward bind localhost port 24224 </source> Then, to send logs via fluent in Logstash format, add the following to the salt (master and/or minion) configuration file: .. code-block:: yaml fluent_handler: host: localhost port: 24224 To send logs via fluent in the Graylog raw json format, add the following to the salt (master and/or minion) configuration file: .. code-block:: yaml fluent_handler: host: localhost port: 24224 payload_type: graylog tags: - salt_master.SALT The above also illustrates the `tags` option, which allows one to set descriptive (or useful) tags on records being sent. If not provided, this defaults to the single tag: 'salt'. Also note that, via Graylog "magic", the 'facility' of the logged message is set to 'SALT' (the portion of the tag after the first period), while the tag itself will be set to simply 'salt_master'. This is a feature, not a bug :) Note: There is a third emitter, for the GELF format, but it is largely untested, and I don't currently have a setup supporting this config, so while it runs cleanly and outputs what LOOKS to be valid GELF, any real-world feedback on its usefulness, and correctness, will be appreciated. Log Level ......... The ``fluent_handler`` configuration section accepts an additional setting ``log_level``. If not set, the logging level used will be the one defined for ``log_level`` in the global configuration file section. .. admonition:: Inspiration This work was inspired in `fluent-logger-python`_ .. _fluentd: http://www.fluentd.org .. _`fluent-logger-python`: https://github.com/fluent/fluent-logger-python � N)� LOG_LEVELSZfluent� � � � � � )ZEMERG�ALERTZCRITZERR�WARNINGZNOTICE�INFO�DEBUGc K s* |� dd�}|� dd�}t| ||d�ad S )N�host� localhost�port�^ �r r )�get�FluentSender�_global_sender)�tag�kwargsr r � r �P/opt/saltstack/salt/lib/python3.10/site-packages/salt/log_handlers/fluent_mod.py�setupl s r c C s t S �N)r r r r r �get_global_sendert s r c C s t dtv g�st�d� dS tS )N�fluent_handlerz�The required configuration section, 'fluent_handler', was not found the in the configuration. Not loading the fluent logging handlers module.F)�any�__opts__�logZtrace�__virtualname__r r r r �__virtual__x s �r! c c s � d } }dt v rt d �dd �} t d �dd �}t d �dd �}t d �ddg�}|r0|d nd}|dkr9d}n|d kr@d }n d}t d �dd �}| d u rX|d u rXt�d� n't|||d�}t|| |d�}|�|� |�tt d �dt �dd�� � |V | d u r�|d u r�dV d S d S d S )Nr r r �payload_type�tags�saltr Zgraylog�gelfg�������?Zlogstash�version� z�The required 'fluent_handler' configuration keys, 'host' and/or 'port', are not properly configured. Not enabling the fluent logging handler.)r"