Bug #90678 dragnet logging: Document the fact that multi-line rules work
Submitted: 29 Apr 2018 7:45 Modified: 20 Jun 2018 5:37
Reporter: Simon Mudd (OCA) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Documentation Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: dragnet, logging

[29 Apr 2018 7:45] Simon Mudd
Description:
dragnet logging may require several rules. It looks like you can only use a single line to describe this which gets messy and hard to read.

I'd like to be able to define rules which work on multiple lines and it looks like this is possible but this is not mentioned explicitly in any of the current documentation.

How to repeat:
So something like this actually works (and to me looks much neater)

root@myhost [(none)]> set global dragnet.log_error_filter_rules =' 
'> IF err_code == 10927 or err_code == 10914 or err_code == 10926 then drop. 
'> IF err_code == 999 then drop. 
'> IF err_code == 1234 then drop.'; 
Query OK, 0 rows affected, 1 warning (0.00 sec) 

root@myhost [(none)]> select @@dragnet.log_error_filter_rules; 
+-----------------------------------------------------------------------------------------------------------------------------------------+ 
| @@dragnet.log_error_filter_rules | 
+-----------------------------------------------------------------------------------------------------------------------------------------+ 
| 
IF err_code == 10927 or err_code == 10914 or err_code == 10926 then drop. 
IF err_code == 999 then drop. 
IF err_code == 1234 then drop. | 
+-----------------------------------------------------------------------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

My understanding is the language accepts this at the moment which is good.

Suggested fix:
* Please _document_ this as being a valid way of introducing rules (e.g. with new line between rules) so this doesn't change all of a sudden
* Please _document_ some more real life examples such as increasing the debug level to catch some special behaviour. Support people can probably help give some ideas here.

If you start to add comments as suggested in bug#90677 then the whole thing will be much easier for people to understand and maintain.
[29 Apr 2018 8:15] Simon Mudd
Adjust synopsis
[19 Jun 2018 15:17] Paul DuBois
Posted by developer:
 
This is fragile. For example, it doesn't work in my.cnf files.

[mysqld]
dragnet.log_error_filter_rules= '
IF prio>=INFORMATION THEN drop.
IF EXISTS source_line THEN unset source_line.'

2018-05-10T16:41:35.606869Z 0 [ERROR] [MY-013111] [Server] Variable 'dragnet.log_error_filter_rules' can't be set to the value of '''
2018-05-10T16:41:35.606904Z 0 [Warning] [MY-011261] [Server] The log-filter component "dragnet" got confused at "'" (state: getting first token ...) ...
2018-05-10T16:41:35.607467Z 0 [ERROR] [MY-011071] [Server] unknown variable 'IF prio>=INFORMATION THEN drop.'
[20 Jun 2018 5:37] Simon Mudd
Paul,

I did not say that this would work from /etc/my.cnf so suggesting that is fragile I think is not appropriate. I think this probably would work for the new persistent storage configuration settings (potentially) as that uses JSON.

In any case I expect to have several rules in my filters. Using a single line will make those rules really hard to read and follow which is why I suggested that you accept this from the command line (SQL interface) even if you can nnot use it from /etc/my.cnf.