Module |
Description |
testfilter |
Statement counting Filter - a simple filter that counts the number of SQL statements executed within a session. Results may be viewed via the debug interface. |
qlafilter |
Query Logging Filter - a simple query logging filter that write all statements for a session into a log file for that session. |
regexfilter |
Query Rewrite Filter - an example of how filters can alter the query contents. This filter allows a regular expression to be defined, along with replacement text that should be substituted for every match of that regular expression. |
tee |
A filter that duplicates SQL requests and sends the duplicates to another service within MaxScale. |
topfilter |
A filter that records the top running queries in terms of execution time. The number of queries to maintain is configurable, upon completion of a session a log file is written with the details of those top queries. |
These filters are merely examples of what may be achieved with the filter API and are not sophisticated or consider as suitable for production use, they merely illustrate the functionality possible.
## Statement Counting Filter
The statement counting filter is implemented in the module names testfilter and merely keeps a count of the number of SQL statements executed. The filter requires no options to be passed and takes no parameters. The statement count can be viewed via the diagnostic and debug interface of MaxScale.
In order to add this filter to an existing service create a filter section to name the filter as follows
[counter]
type=filter
module=testfilter
Then add the filter to your service by including the filters= parameter in the service section.
filters=counter
## Query Log All Filter
The QLA filter simply writes all SQL statements to a log file along with a timestamp for the statement. An example of the file produced by the QLA filter is shown below
00:36:04.922 5/06/2014, select @@version_comment limit 1
00:36:12.663 5/06/2014, SELECT DATABASE()
00:36:12.664 5/06/2014, show databases
00:36:12.665 5/06/2014, show tables
A new file is created for each client connection, the name of the logfile can be controlled by the use of the router options. No parameters are used by the QLA filter. The filter is implemented by the loadable module qlafilter.
To add the QLA filter to a service you must create a filter section to name the filter, associated the loadable module and define the filename option.
[QLA]
type=filter
module=qlafilter
options=/tmp/QueryLog
Then add the filters= parameter into the service that you wish to log by adding this parameter to the service section
filters=QLA
A log file will be created for each client connection, the name of that log file will be /tmp/QueryLog.