mentat.daemon.component.inspector module¶
Daemon component providing simple yet powerfull message processing tools based on performing conditional actions according to list of filtering rules.
It is dependent on services of following modules:
-
Filtering rule library.
-
Filtering rule compilation library.
The implementation is based on pyzenkit.zendaemon.ZenDaemonComponent
.
Setup configuration¶
This daemon component requires that following configurations are provided by external daemon:
- inspection_rules
List of inspection rules. See section Inspection rules below for more information about available actions.
- fallback_actions
List of fallback actions. See section Inspection actions below for more information about available actions.
Inspection rules¶
Inspection rules define what actions should be performed with what messages. Every inspection rule may have following attributes:
- rule
Filtering rule compatible with
pynspect.filters
library. All messages will be compared to this rule and actions will be performed with those that match.(
string
, mandatory)- name
Optional name for the rule to be used in logs and other user output. This should be something brief and meaningfull to uniquelly identify the rule. When not set this defaults to rule attribute.
(
string
, optional)- description
Optional user description of the meaning of the rule. When not set defaults to
???
.(
string
, optional)- final
Boolean flag indicating the rule is final and all subsequent rules should not be considered. When not set defaults to
False
.(
boolean
, optional)- enabled
Boolean flag indicating the rule is enabled or disabled. When not set defaults to
True
.(
boolean
, optional)- actions
List of inspection action to be performed upon filter match. See section Inspection actions for more details.
Inspection actions¶
Every action has following common attributes:
- action
Type of the action. See below for list of all currently available actions.
(
string
, mandatory)- name
Optional name for the action to be used in logs and other user output. This should be something brief and meaningfull to uniquelly identify the action. When not set this defaults to action attribute.
(
string
, optional)- description
Optional user description of the meaning of the action. When not set defaults to
???
.(
string
, optional)- enabled
Boolean flag indicating the action is enabled or disabled. When not set defaults to
True
.(
boolean
, optional)- args
Dictionary of additional arguments for the action. The appropriate arguments are specific for particular action. See below for more information for each action.
(
dict
, optional)
There are following inspection actions, that can be performed with matching messages or as fallback action:
- tag
Tag the corresponding message at given JPath with given value. The tag value may be only constant value.
Arguments:
path -
JPath
to be set (string
, mandatory)value - value to be set (
any
, mandatory)overwrite - flag indicating whether existing value should be overwritten, or not, defaults to
True
(boolean
, optional)unique - flag indicating whether value should be unique, or not, defaults to
False
(boolean
, optional)
- set
Set the corresponding message at given JPath with result of given expression. The expression must be compatible with
JPath
module.Arguments:
path -
JPath
to be set (string
, mandatory)expression -
JPath
compatible expression to be set (string
, mandatory)overwrite - flag indicating whether existing value should be overwritten, or not, defaults to
True
(boolean
, optional)unique - flag indicating whether value should be unique, or not, defaults to
False
(boolean
, optional)
- unset
Unset (delete) the node at given JPath within the message.
Arguments:
path -
JPath
to be deleted (string
, mandatory)
- report
Report the corresponding message via email.
Arguments:
to - recipient email address (
string
, mandatory)from - sender email address (
string
, mandatory)subject - email report subject (
string
, mandatory)report_type - email report type, will be inserted into
X-Cesnet-Report-Type
email header (string
, mandatory)
Todo
Finish usage of default arguments and then update this documentation. Currently every argument is mandatory, which makes users repeat themselves.
- drop
Drop the corresponding message from processing (filter out).
This action currently does not have any arguments.
- dispatch
Dispatch (move) the corresponding message into another queue directory.
Arguments:
queue_tgt - path to target queue (
string
, mandatory)
- duplicate
Duplicate (copy) the corresponding message into another queue directory.
Arguments:
queue_tgt - path to target queue (
string
, mandatory)
- log
Log the corresponding message into daemon module log.
Arguments:
label - log message label, defaults to
Inspection rule matched
(string
, optional)
-
class
mentat.daemon.component.inspector.
InspectorDaemonComponent
(**kwargs)[source]¶ Bases:
pyzenkit.zendaemon.ZenDaemonComponent
ZenDaemonComponent encapsulating pynspect library and providing.
-
EVENT_LOG_STATISTICS
= 'log_statistics'¶
-
EVENT_MSG_PROCESS
= 'message_process'¶
-
STATS_CNT_DISPATCHED
= 'cnt_dispatched'¶
-
STATS_CNT_DROPPED
= 'cnt_dropped'¶
-
STATS_CNT_DUPLICATED
= 'cnt_duplicated'¶
-
STATS_CNT_ERRORS
= 'cnt_errors'¶
-
STATS_CNT_FALLBACKS
= 'cnt_fallbacks'¶
-
STATS_CNT_LOGGED
= 'cnt_logged'¶
-
STATS_CNT_REPORTED
= 'cnt_reported'¶
-
STATS_CNT_SET
= 'cnt_set'¶
-
STATS_CNT_TAGGED
= 'cnt_tagged'¶
-
STATS_CNT_UNSET
= 'cnt_unset'¶
-
STATS_COUNTERS
= 'counters'¶
-
rule_action_dispatch
(daemon, mid, iid, message, action, rule=None)[source]¶ Dispatch given message into given target queue.
-
rule_action_drop
(daemon, mid, iid, message, action, rule=None)[source]¶ Drop given messsage from processing.
-
rule_action_duplicate
(daemon, mid, iid, message, action, rule=None)[source]¶ Duplicate given message into given target queue.
-
rule_action_log
(daemon, mid, iid, message, action, rule=None)[source]¶ Log matching message with warning severity.
-
rule_action_report
(daemon, mid, iid, message, action, rule=None)[source]¶ Report given message according given arguments.
-
rule_action_set
(daemon, mid, iid, message, action, rule=None)[source]¶ Set given message key according given arguments.
-
rule_action_tag
(daemon, mid, iid, message, action, rule=None)[source]¶ Tag given message according given arguments.
-