|
| enum | enum_log_filter_xlate_flags {
LOG_FILTER_XLATE_NONE = 0
, LOG_FILTER_XLATE_COND = 1
, LOG_FILTER_XLATE_REF = 2
, LOG_FILTER_XLATE_PREFIX = 4
,
LOG_FILTER_XLATE_LITERAL = 8
, LOG_FILTER_XLATE_VERB = 32
, LOG_FILTER_XLATE_AUXNAME = 64
, LOG_FILTER_XLATE_AUXVAL = 128
,
LOG_FILTER_XLATE_FLOW = 1024
, LOG_FILTER_XLATE_CHAIN = 2048
} |
| | Flags to use in log_filter_xlate_by_name() / log_filter_xlate_by_opcode() when looking up a token by its opcode, or vice versa. More...
|
| |
| enum | enum_log_filter_token_flags {
LOG_FILTER_TOKEN_NONE = 0
, LOG_FILTER_TOKEN_NAME = 1
, LOG_FILTER_TOKEN_NUMERIC = 2
, LOG_FILTER_TOKEN_COMP = 4
,
LOG_FILTER_TOKEN_ARG = 32
, LOG_FILTER_TOKEN_ACTION = 64
, LOG_FILTER_TOKEN_KEYWORD = 128
} |
| | What kind of token should log_filter_get_token() look for? More...
|
| |
| enum | enum_log_filter_syntax {
LOG_FILTER_WORD_NONE = 0
, LOG_FILTER_WORD_IF = 1
, LOG_FILTER_WORD_THEN = 2
, LOG_FILTER_WORD_ELSEIF = 3
,
LOG_FILTER_WORD_ELSE = 4
} |
| | A few keywords that we look for while parsing, but that do not necessarily generate an opcode in the rule-set. More...
|
| |
| enum | enum_log_filter_result {
LOG_FILTER_LANGUAGE_OK = 0
, LOG_FILTER_LANGUAGE_DK_COND = 1
, LOG_FILTER_LANGUAGE_DK_VERB = 2
, LOG_FILTER_LANGUAGE_DK_CLASS = 3
,
LOG_FILTER_LANGUAGE_OOM = 4
, LOG_FILTER_LANGUAGE_GET_FAILED = 5
, LOG_FILTER_LANGUAGE_CHAIN = 6
} |
| | result codes used in dumping/decompiling rules More...
|
| |
| enum | enum_set_arg_result {
SET_ARG_SUCCESS = 0
, SET_ARG_OOM = -1
, SET_ARG_MALFORMED_FLOAT = -2
, SET_ARG_DK_CLASS = -3
,
SET_ARG_UNWANTED_NUMERIC = -4
, SET_ARG_UNWANTED_STRING = -5
, SET_ARG_MALFORMED_VALUE = -6
, SET_ARG_UNWANTED_FLOAT = -7
,
SET_ARG_FRACTION_FOUND = -8
} |
| | result codes of log_filter_set_arg() More...
|
| |
|
| | REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_register) |
| |
| | REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_unregister) |
| |
| | REQUIRES_SERVICE_PLACEHOLDER (status_variable_registration) |
| |
| | STR_CHECK_ARG (rules) values_filter_rules |
| | limits and default for sysvar More...
|
| |
| | REQUIRES_SERVICE_PLACEHOLDER (log_builtins) |
| |
| | REQUIRES_SERVICE_PLACEHOLDER (log_builtins_string) |
| |
| | REQUIRES_SERVICE_PLACEHOLDER (log_builtins_filter) |
| |
| | REQUIRES_SERVICE_PLACEHOLDER (log_builtins_tmp) |
| |
| static int | log_filter_xlate_by_name (const char *token, size_t len, uint flags) |
| | Find a given token in log_filter_xlate_keys[], the table of known tokens. More...
|
| |
| static int | log_filter_xlate_by_opcode (uint opcode, uint flags) |
| | Find a given opcode in log_filter_xlate_keys[], the table of known tokens. More...
|
| |
| static void | log_filter_append (char *out_buf, size_t out_siz, const char *str) |
| | Helper for dumping filter rules. More...
|
| |
| static void | log_filter_append_item_value (char *out_buf, size_t out_siz, log_item *li) |
| | Helper for dumping filter rules. More...
|
| |
| static log_filter_result | log_filter_rule_dump (log_filter_rule *rule, log_filter_result state, char *out_buf, size_t out_size) |
| | Decompile an individual rule. More...
|
| |
| log_filter_result | log_filter_ruleset_dump (log_filter_ruleset *ruleset, char *ruleset_buf, size_t siz) |
| | Dump an entire filter rule-set. More...
|
| |
| static void | log_filter_skip_white (const char **inp_readpos) |
| | Skip whitespace. More...
|
| |
| static int | log_filter_get_token (const char **inp_readpos, const char **token, size_t *len, uint types) |
| | Gets a token from a filter configuration. More...
|
| |
| static int | log_filter_make_field (const char **name, const size_t *len, log_item *li) |
| | Set up a log-item from filtering rules. More...
|
| |
| static bool | log_filter_generic_type (log_item_type type) |
| | Helper: Does a field require a certain data class, or can it morph into whatever value we wish to assign to it? The former is the case if the field either has a generic (rather than well-known) type, or if it has no type at all (this is the case if a rule has an unnamed aux item). More...
|
| |
| static set_arg_result | log_filter_set_arg (const char **token, const size_t *len, log_item *li, const char **state) |
| | Set argument (i.e., the value) on a list-item. More...
|
| |
| static int | log_filter_dragnet_set (log_filter_ruleset *ruleset, const char *rules, const char **state) |
| | Set filtering rules from human-readable configuration string. More...
|
| |
| static int | check_var_filter_rules (MYSQL_THD thd, SYS_VAR *self, void *save, struct st_mysql_value *value) |
| | Check the proposed value for the component variable which contains the filter rules in human-readable format. More...
|
| |
| static void | update_var_filter_rules (MYSQL_THD thd, SYS_VAR *self, void *var_ptr, const void *save) |
| | Update value of component variable. More...
|
| |
| mysql_service_status_t | log_filter_exit () |
| | De-initialization method for Component used when unloading the Component. More...
|
| |
| mysql_service_status_t | log_filter_init () |
| | Initialization entry method for Component used when loading the Component. More...
|
| |
| | PROVIDES_SERVICE (log_filter_dragnet, log_service) |
| |
| | END_COMPONENT_PROVIDES () |
| |
| | REQUIRES_SERVICE (component_sys_variable_register) |
| |
| | REQUIRES_SERVICE (component_sys_variable_unregister) |
| |
| | REQUIRES_SERVICE (status_variable_registration) |
| |
| | REQUIRES_SERVICE (log_builtins) |
| |
| | REQUIRES_SERVICE (log_builtins_string) |
| |
| | REQUIRES_SERVICE (log_builtins_filter) |
| |
| | REQUIRES_SERVICE (log_builtins_tmp) |
| |
| | END_COMPONENT_REQUIRES () |
| |
| | METADATA ("mysql.author", "Oracle Corporation") |
| |
| | METADATA ("mysql.license", "GPL") |
| |
| | METADATA ("log_service_type", "filter") |
| |
| | END_COMPONENT_METADATA () |
| |
| #define LOG_FILTER_DUMP_BUFF_SIZE 8192 |
There is a new filter engine in the server proper (components/mysql_server/log_builtins_filter.cc).
It can apply highly versatile filtering rules to log events. By default however, it loads a rule-set that emulates mysqld 5.7 behavior, so as far as the users are concerned, the configuration variables (–log_error_verbosity ...) and the behavior haven't changed (much).
The loadable service implemented in this file is noteworthy in that it does not implement a complete filtering service; instead, it implements a configuration language for the internal filter that gives users access to all its features (rather than just to the small 5.7 compatibility subset).
Therefore, this file contains the parsing of the new configuration language (the "configuration engine"), whereas log_builtins_filter.cc contains the filtering engine.
CONFIGURATION PARSING STAGE
As a courtesy, during parsing (e.g. "IF prio>=3 THEN drop."), the filter configuration engine checks whether it knows the field ("prio"), and if so, whether the storage class it expects for the field (integer) matches that of the argument (3). In our example, it does; if it didn't, the configuration engine would throw an error.
The same applies if a well-known field appears in the action (e.g. the action 'set log_label:="HELO".' in the rule 'IF err_code==1408 THEN set label:="HELO".') label is a well-known field here, its well-known storage class is string, and since "HELO" is a string, all's well. (Otherwise, again, we'd throw an error.)
| static int log_filter_dragnet_set |
( |
log_filter_ruleset * |
ruleset, |
|
|
const char * |
rules, |
|
|
const char ** |
state |
|
) |
| |
|
static |
Set filtering rules from human-readable configuration string.
- Parameters
-
| ruleset | ruleset to update |
| rules | a NTBS containing zero, one, or many rules |
| [out] | state | a pointer to additional info about the state. (this is free-text intended for error messages.) |
- Return values
-
| 0 | no problems |
| -1 | could not acquire ruleset |
| -2 | out of memory |
| -3 | invalid arguments |
| >0 | parse problem at this index in rule string |
< current rule
< previous rule, if any
< read position in submitted rules
< retry from here on misparse
< current token in input
< token's length
< counter
< return code for caller
< previous flow control command
< current flow control command
< rule that had the opening IF
< number of conditions in branch
< the rule-set we're creating
< implicit item for "unset"
< have half-finished rule?
| static set_arg_result log_filter_set_arg |
( |
const char ** |
token, |
|
|
const size_t * |
len, |
|
|
log_item * |
li, |
|
|
const char ** |
state |
|
) |
| |
|
static |
Set argument (i.e., the value) on a list-item.
If the item is of any generic type, we'll set the value, and adjust the type to be of an appropriate ad hoc type. If the item is of a well-known type, we'll set the value on it if it's of an appropriate type, but will fail otherwise. For this, an integer constitutes a valid float, but not vice versa. (A string containing nothing but a number is still not a number.)
- Parameters
-
| token | pointer to the beginning of the value-token |
| len | length of the argument/token |
| li | log-item to set the value on |
| [out] | state | a pointer to additional info about the state. (this is free-text intended for error messages.) |
- Returns
- set_arg_result; 0 for success, !0 for failure