<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="error-log-rule-based-filtering">
      </a>
      7.4.2.6 Rule-Based Error Log Filtering (log_filter_dragnet)
     </h4>
    </div>
   </div>
  </div>
  <p>
   The
   <code class="literal">
    log_filter_dragnet
   </code>
   log filter component
        enables log filtering based on user-defined rules.
  </p>
  <p>
   To enable the
   <code class="literal">
    log_filter_dragnet
   </code>
   filter,
        first load the filter component, then modify the
   <a class="link" href="server-system-variables.html#sysvar_log_error_services">
    <code class="literal">
     log_error_services
    </code>
   </a>
   value. The
        following example enables
   <code class="literal">
    log_filter_dragnet
   </code>
   in combination with the built-in log sink:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4617011"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component_log_filter_dragnet'</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_dragnet; log_sink_internal'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   To set
   <a class="link" href="server-system-variables.html#sysvar_log_error_services">
    <code class="literal">
     log_error_services
    </code>
   </a>
   to
        take effect at server startup, use the instructions at
   <a class="xref" href="error-log-configuration.html" title="7.4.2.1 Error Log Configuration">
    Section 7.4.2.1, “Error Log Configuration”
   </a>
   . Those instructions
        apply to other error-logging system variables as well.
  </p>
  <p>
   With
   <code class="literal">
    log_filter_dragnet
   </code>
   enabled, define its
        filter rules by setting the
   <a class="link" href="server-system-variables.html#sysvar_dragnet.log_error_filter_rules">
    <code class="literal">
     dragnet.log_error_filter_rules
    </code>
   </a>
   system variable. A rule set consists of zero or more rules,
        where each rule is an
   <code class="literal">
    IF
   </code>
   statement terminated
        by a period (
   <code class="literal">
    .
   </code>
   ) character. If the variable
        value is empty (zero rules), no filtering occurs.
  </p>
  <p>
   Example 1. This rule set drops information events, and, for
        other events, removes the
   <code class="literal">
    source_line
   </code>
   field:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59750531"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> dragnet<span class="token punctuation">.</span>log_error_filter_rules <span class="token operator">=</span>
  <span class="token string">'IF prio&gt;=INFORMATION THEN drop. IF EXISTS source_line THEN unset source_line.'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The effect is similar to the filtering performed by the
   <code class="literal">
    log_sink_internal
   </code>
   filter with a setting of
   <a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
    <code class="literal">
     log_error_verbosity=2
    </code>
   </a>
   .
  </p>
  <p>
   For readability, you might find it preferable to list the rules
        on separate lines. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa65232995"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> dragnet<span class="token punctuation">.</span>log_error_filter_rules <span class="token operator">=</span> <span class="token string">'
  IF prio&gt;=INFORMATION THEN drop.
  IF EXISTS source_line THEN unset source_line.
'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   Example 2: This rule limits information events to no more than
        one per 60 seconds:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92804478"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> dragnet<span class="token punctuation">.</span>log_error_filter_rules <span class="token operator">=</span>
  <span class="token string">'IF prio&gt;=INFORMATION THEN throttle 1/60.'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   Once you have the filtering configuration set up as you desire,
        consider assigning
   <a class="link" href="server-system-variables.html#sysvar_dragnet.log_error_filter_rules">
    <code class="literal">
     dragnet.log_error_filter_rules
    </code>
   </a>
   using
   <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    <code class="literal">
     SET
        PERSIST
    </code>
   </a>
   rather than
   <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    <code class="literal">
     SET
        GLOBAL
    </code>
   </a>
   to make the setting persist across server
        restarts. Alternatively, add the setting to the server option
        file.
  </p>
  <p>
   When using
   <code class="literal">
    log_filter_dragnet
   </code>
   ,
   <a class="link" href="server-system-variables.html#sysvar_log_error_suppression_list">
    <code class="literal">
     log_error_suppression_list
    </code>
   </a>
   is
        ignored.
  </p>
  <p>
   To stop using the filtering language, first remove it from the
        set of error logging components. Usually this means using a
        different filter component rather than no filter component. For
        example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa17077236"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_internal'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   Again, consider using
   <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    <code class="literal">
     SET
        PERSIST
    </code>
   </a>
   rather than
   <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    <code class="literal">
     SET
        GLOBAL
    </code>
   </a>
   to make the setting persist across server
        restarts.
  </p>
  <p>
   Then uninstall the filter
   <code class="literal">
    log_filter_dragnet
   </code>
   component:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa38590988"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component_log_filter_dragnet'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The following sections describe aspects of
   <code class="literal">
    log_filter_dragnet
   </code>
   operation in more detail:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-filtering-language" title="Grammar for log_filter_dragnet Rule Language">
       Grammar for log_filter_dragnet Rule Language
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-filtering-actions" title="Actions for log_filter_dragnet Rules">
       Actions for log_filter_dragnet Rules
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-filtering-fields" title="Field References in log_filter_dragnet Rules">
       Field References in log_filter_dragnet Rules
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-dragnet-filtering-language">
       </a>
       Grammar for log_filter_dragnet Rule Language
      </h5>
     </div>
    </div>
   </div>
   <p>
    The following grammar defines the language for
    <code class="literal">
     log_filter_dragnet
    </code>
    filter rules. Each rule
          is an
    <code class="literal">
     IF
    </code>
    statement terminated by a period
          (
    <code class="literal">
     .
    </code>
    ) character. The language is not
          case-sensitive.
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa11116140"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple"><em class="replaceable">rule</em><span class="token operator">:</span>
    IF <em class="replaceable">condition</em> THEN <em class="replaceable">action</em>
    <span class="token punctuation">[</span>ELSEIF <em class="replaceable">condition</em> THEN <em class="replaceable">action</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">[</span>ELSE <em class="replaceable">action</em><span class="token punctuation">]</span>
    <span class="token punctuation">.</span>

<em class="replaceable">condition</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    <em class="replaceable">field</em> <em class="replaceable">comparator</em> <em class="replaceable">value</em>
  <span class="token operator">|</span> <span class="token punctuation">[</span>NOT<span class="token punctuation">]</span> EXISTS <em class="replaceable">field</em>
  <span class="token operator">|</span> <em class="replaceable">condition</em> <span class="token punctuation">{</span>AND <span class="token operator">|</span> OR<span class="token punctuation">}</span>  <em class="replaceable">condition</em>
<span class="token punctuation">}</span>

<em class="replaceable">action</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    drop
  <span class="token operator">|</span> throttle <span class="token punctuation">{</span><em class="replaceable">count</em> <span class="token operator">|</span> <em class="replaceable">count</em> <span class="token operator">/</span> <em class="replaceable">window_size</em><span class="token punctuation">}</span>
  <span class="token operator">|</span> set <em class="replaceable">field</em> <span class="token punctuation">[</span><span class="token operator">:</span><span class="token operator">=</span> <span class="token operator">|</span> <span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">value</em>
  <span class="token operator">|</span> unset <span class="token punctuation">[</span><em class="replaceable">field</em><span class="token punctuation">]</span>
<span class="token punctuation">}</span>

<em class="replaceable">field</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    <em class="replaceable">core_field</em>
  <span class="token operator">|</span> <em class="replaceable">optional_field</em>
  <span class="token operator">|</span> <em class="replaceable">user_defined_field</em>
<span class="token punctuation">}</span>

<em class="replaceable">core_field</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    time
  <span class="token operator">|</span> msg
  <span class="token operator">|</span> prio
  <span class="token operator">|</span> err_code
  <span class="token operator">|</span> err_symbol
  <span class="token operator">|</span> SQL_state
  <span class="token operator">|</span> subsystem
<span class="token punctuation">}</span>

<em class="replaceable">optional_field</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    OS_errno
  <span class="token operator">|</span> OS_errmsg
  <span class="token operator">|</span> label
  <span class="token operator">|</span> user
  <span class="token operator">|</span> host
  <span class="token operator">|</span> thread
  <span class="token operator">|</span> query_id
  <span class="token operator">|</span> source_file
  <span class="token operator">|</span> source_line
  <span class="token operator">|</span> function
  <span class="token operator">|</span> component
<span class="token punctuation">}</span>

<em class="replaceable">user_defined_field</em><span class="token operator">:</span>
    <em class="replaceable">sequence of characters in <span class="token punctuation">[</span>a<span class="token operator">-</span>zA<span class="token operator">-</span>Z0<span class="token operator">-</span>9_<span class="token punctuation">]</span> class</em>

<em class="replaceable">comparator</em><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token operator">==</span> <span class="token operator">|</span> <span class="token operator">!=</span> <span class="token operator">|</span> <span class="token operator">&lt;</span><span class="token operator">&gt;</span> <span class="token operator">|</span> <span class="token operator">&gt;=</span> <span class="token operator">|</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token operator">|</span> <span class="token operator">&lt;=</span> <span class="token operator">|</span> <span class="token operator">=</span><span class="token operator">&lt;</span> <span class="token operator">|</span> <span class="token operator">&lt;</span> <span class="token operator">|</span> <span class="token operator">&gt;</span><span class="token punctuation">}</span>

<em class="replaceable">value</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    <em class="replaceable">string_literal</em>
  <span class="token operator">|</span> <em class="replaceable">integer_literal</em>
  <span class="token operator">|</span> <em class="replaceable">float_literal</em>
  <span class="token operator">|</span> <em class="replaceable">error_symbol</em>
  <span class="token operator">|</span> <em class="replaceable">priority</em>
<span class="token punctuation">}</span>

<em class="replaceable">count</em><span class="token operator">:</span> <em class="replaceable">integer_literal</em>
<em class="replaceable">window_size</em><span class="token operator">:</span> <em class="replaceable">integer_literal</em>

<em class="replaceable">string_literal</em><span class="token operator">:</span>
    <em class="replaceable">sequence of characters quoted as '<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>' or "<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>"</em>

<em class="replaceable">integer_literal</em><span class="token operator">:</span>
    <em class="replaceable">sequence of characters in <span class="token punctuation">[</span>0<span class="token operator">-</span>9<span class="token punctuation">]</span> class</em>

<em class="replaceable">float_literal</em><span class="token operator">:</span>
    <em class="replaceable">integer_literal</em><span class="token punctuation">[</span><span class="token punctuation">.</span><em class="replaceable">integer_literal</em><span class="token punctuation">]</span>

<em class="replaceable">error_symbol</em><span class="token operator">:</span>
    <em class="replaceable">valid MySQL error symbol such as ER_ACCESS_DENIED_ERROR or ER_STARTUP</em>

<em class="replaceable">priority</em><span class="token operator">:</span> <span class="token punctuation">{</span>
    ERROR
  <span class="token operator">|</span> WARNING
  <span class="token operator">|</span> INFORMATION
<span class="token punctuation">}</span></code></pre>
   </div>
   <p>
    Simple conditions compare a field to a value or test field
          existence. To construct more complex conditions, use the
    <code class="literal">
     AND
    </code>
    and
    <code class="literal">
     OR
    </code>
    operators.
          Both operators have the same precedence and evaluate left to
          right.
   </p>
   <p>
    To escape a character within a string, precede it by a
          backslash (
    <code class="literal">
     \
    </code>
    ). A backslash is required to
          include backslash itself or the string-quoting character,
          optional for other characters.
   </p>
   <p>
    For convenience,
    <code class="literal">
     log_filter_dragnet
    </code>
    supports symbolic names for comparisons to certain fields. For
          readability and portability, symbolic values are preferable
          (where applicable) to numeric values.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Event priority values 1, 2, and 3 can be specified as
       <code class="literal">
        ERROR
       </code>
       ,
       <code class="literal">
        WARNING
       </code>
       , and
       <code class="literal">
        INFORMATION
       </code>
       . Priority symbols are
              recognized only in comparisons with the
       <code class="literal">
        prio
       </code>
       field. These comparisons are
              equivalent:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa21641723"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">=</span><span class="token operator">=</span> INFORMATION <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">IF</span> prio <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">3</span> <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       Error codes can be specified in numeric form or as the
              corresponding error symbol. For example,
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_startup" target="_top">
        <code class="literal">
         ER_STARTUP
        </code>
       </a>
       is the symbolic
              name for error
       <code class="literal">
        1408
       </code>
       , so these
              comparisons are equivalent:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa39210395"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> ER_STARTUP <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">1408</span> <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
      </div>
      <p>
       Error symbols are recognized only in comparisons with the
       <code class="literal">
        err_code
       </code>
       field and user-defined fields.
      </p>
      <p>
       To find the error symbol corresponding to a given error
              code number, use one of these methods:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          Check the list of server errors at
          <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
           Server Error Message Reference
          </a>
          .
         </p>
        </li>
        <li class="listitem">
         <p>
          Use the
          <a class="link" href="perror.html" title="6.8.1 perror — Display MySQL Error Message Information">
           <span class="command">
            <strong>
             perror
            </strong>
           </span>
          </a>
          command. Given an
                  error number argument,
          <a class="link" href="perror.html" title="6.8.1 perror — Display MySQL Error Message Information">
           <span class="command">
            <strong>
             perror
            </strong>
           </span>
          </a>
          displays information about the error, including its
                  symbol.
         </p>
        </li>
       </ul>
      </div>
      <p>
       Suppose that a rule set with error numbers looks like
              this:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12698513"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">10927</span> <span class="token operator">OR</span> err_code <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">10914</span> <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span>
<span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">1131</span> <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span></code></pre>
      </div>
      <p>
       Using
       <a class="link" href="perror.html" title="6.8.1 perror — Display MySQL Error Message Information">
        <span class="command">
         <strong>
          perror
         </strong>
        </span>
       </a>
       , determine the error
              symbols:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa96826383"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">perror</span> 10927 10914 1131
MySQL error code MY-010927 <span class="token punctuation">(</span>ER_ACCESS_DENIED_FOR_USER_ACCOUNT_LOCKED<span class="token punctuation">)</span><span class="token punctuation">:</span>
Access denied for user <span class="token atrule">'%-.48s'</span>@<span class="token atrule">'%-.64s'</span><span class="token punctuation">.</span> Account is locked<span class="token punctuation">.</span>
MySQL error code MY-010914 <span class="token punctuation">(</span>ER_ABORTING_USER_CONNECTION<span class="token punctuation">)</span><span class="token punctuation">:</span>
Aborted connection %u to db<span class="token punctuation">:</span> <span class="token atrule">'%-.192s'</span> user<span class="token punctuation">:</span> <span class="token atrule">'%-.48s'</span> host<span class="token punctuation">:</span>
<span class="token atrule">'%-.64s'</span> <span class="token punctuation">(</span>%-<span class="token punctuation">.</span>64s<span class="token punctuation">)</span><span class="token punctuation">.</span>
MySQL error code MY-001131 <span class="token punctuation">(</span>ER_PASSWORD_ANONYMOUS_USER<span class="token punctuation">)</span><span class="token punctuation">:</span>
You are using MySQL as an anonymous user and anonymous users
are not allowed to change passwords</code></pre>
      </div>
      <p>
       Substituting error symbols for numbers, the rule set
              becomes:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34039885"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> ER_ACCESS_DENIED_FOR_USER_ACCOUNT_LOCKED
  <span class="token operator">OR</span> err_code <span class="token operator">=</span><span class="token operator">=</span> ER_ABORTING_USER_CONNECTION <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span>
<span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> ER_PASSWORD_ANONYMOUS_USER <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    Symbolic names can be specified as quoted strings for
          comparison with string fields, but in such cases the names are
          strings that have no special meaning and
    <code class="literal">
     log_filter_dragnet
    </code>
    does not resolve them to
          the corresponding numeric value. Also, typos may go
          undetected, whereas an error occurs immediately on
    <code class="literal">
     SET
    </code>
    for attempts to use an unquoted symbol
          unknown to the server.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-dragnet-filtering-actions">
       </a>
       Actions for log_filter_dragnet Rules
      </h5>
     </div>
    </div>
   </div>
   <p>
    <code class="literal">
     log_filter_dragnet
    </code>
    supports these actions
          in filter rules:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        drop
       </code>
       : Drop the current log event (do
              not log it).
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        throttle
       </code>
       : Apply rate limiting to reduce
              log verbosity for events matching particular conditions.
              The argument indicates a rate, in the form
       <em class="replaceable">
        <code>
         count
        </code>
       </em>
       or
       <em class="replaceable">
        <code>
         count
        </code>
       </em>
       /
       <em class="replaceable">
        <code>
         window_size
        </code>
       </em>
       .
              The
       <em class="replaceable">
        <code>
         count
        </code>
       </em>
       value indicates the
              permitted number of event occurrences to log per time
              window. The
       <em class="replaceable">
        <code>
         window_size
        </code>
       </em>
       value
              is the time window in seconds; if omitted, the default
              window is 60 seconds. Both values must be integer
              literals.
      </p>
      <p>
       This rule throttles plugin-shutdown messages to 5
              occurrences per 60 seconds:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64309872"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> ER_PLUGIN_SHUTTING_DOWN_PLUGIN <span class="token keyword">THEN</span> throttle <span class="token number">5</span><span class="token punctuation">.</span></code></pre>
      </div>
      <p>
       This rule throttles errors and warnings to 1000
              occurrences per hour and information messages to 100
              occurrences per hour:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64509969"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">&lt;=</span> INFORMATION <span class="token keyword">THEN</span> throttle <span class="token number">1000</span><span class="token operator">/</span><span class="token number">3600</span> <span class="token keyword">ELSE</span> throttle <span class="token number">100</span><span class="token operator">/</span><span class="token number">3600</span><span class="token punctuation">.</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        set
       </code>
       : Assign a value to a field (and
              cause the field to exist if it did not already). In
              subsequent rules,
       <code class="literal">
        EXISTS
       </code>
       tests against
              the field name are true, and the new value can be tested
              by comparison conditions.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        unset
       </code>
       : Discard a field. In subsequent
              rules,
       <code class="literal">
        EXISTS
       </code>
       tests against the field
              name are false, and comparisons of the field against any
              value are false.
      </p>
      <p>
       In the special case that the condition refers to exactly
              one field name, the field name following
       <code class="literal">
        unset
       </code>
       is optional and
       <code class="literal">
        unset
       </code>
       discards the named field. These
              rules are equivalent:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91475582"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> myfield <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">2</span> <span class="token keyword">THEN</span> unset myfield<span class="token punctuation">.</span>
<span class="token keyword">IF</span> myfield <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">2</span> <span class="token keyword">THEN</span> unset<span class="token punctuation">.</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-dragnet-filtering-fields">
       </a>
       Field References in log_filter_dragnet Rules
      </h5>
     </div>
    </div>
   </div>
   <p>
    <code class="literal">
     log_filter_dragnet
    </code>
    rules support references
          to core, optional, and user-defined fields in error events.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-core-field-references" title="Core Field References">
        Core Field References
       </a>
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-optional-field-references" title="Optional Field References">
        Optional Field References
       </a>
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-user-defined-field-references" title="User-Defined Field References">
        User-Defined Field References
       </a>
      </p>
     </li>
    </ul>
   </div>
   <h6>
    <a name="error-log-dragnet-core-field-references">
    </a>
    Core Field References
   </h6>
   <p>
    The
    <code class="literal">
     log_filter_dragnet
    </code>
    grammar at
    <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-filtering-language" title="Grammar for log_filter_dragnet Rule Language">
     Grammar for log_filter_dragnet Rule Language
    </a>
    names
          the core fields that filter rules recognize. For general
          descriptions of these fields, see
    <a class="xref" href="error-log-event-fields.html" title="7.4.2.3 Error Event Fields">
     Section 7.4.2.3, “Error Event Fields”
    </a>
    , with which you are
          assumed to be familiar. The following remarks provide
          additional information only as it pertains specifically to
          core field references as used within
    <code class="literal">
     log_filter_dragnet
    </code>
    rules.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        prio
       </code>
      </p>
      <p>
       The event priority, to indicate an error, warning, or
              note/information event. In comparisons, each priority can
              be specified as a symbolic priority name or an integer
              literal. Priority symbols are recognized only in
              comparisons with the
       <code class="literal">
        prio
       </code>
       field. These
              comparisons are equivalent:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa65630554"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">=</span><span class="token operator">=</span> INFORMATION <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">IF</span> prio <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">3</span> <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
      </div>
      <p>
       The following table shows the permitted priority levels.
      </p>
      <div class="informaltable">
       <table summary="Error event priority levels.">
        <colgroup>
         <col style="width: 25%"/>
         <col style="width: 25%"/>
         <col style="width: 25%"/>
        </colgroup>
        <thead>
         <tr>
          <th scope="col">
           Event Type
          </th>
          <th scope="col">
           Priority Symbol
          </th>
          <th scope="col">
           Numeric Priority
          </th>
         </tr>
        </thead>
        <tbody>
         <tr>
          <th align="left" scope="row">
           Error event
          </th>
          <td>
           <code class="literal">
            ERROR
           </code>
          </td>
          <td>
           1
          </td>
         </tr>
         <tr>
          <th align="left" scope="row">
           Warning event
          </th>
          <td>
           <code class="literal">
            WARNING
           </code>
          </td>
          <td>
           2
          </td>
         </tr>
         <tr>
          <th align="left" scope="row">
           Note/information event
          </th>
          <td>
           <code class="literal">
            INFORMATION
           </code>
          </td>
          <td>
           3
          </td>
         </tr>
        </tbody>
       </table>
      </div>
      <p>
       There is also a message priority of
       <code class="literal">
        SYSTEM
       </code>
       , but system messages cannot be
              filtered and are always written to the error log.
      </p>
      <p>
       Priority values follow the principle that higher
              priorities have lower values, and vice versa. Priority
              values begin at 1 for the most severe events (errors) and
              increase for events with decreasing priority. For example,
              to discard events with priority lower than warnings, test
              for priority values higher than
       <code class="literal">
        WARNING
       </code>
       :
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa13729542"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">&gt;</span> WARNING <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span></code></pre>
      </div>
      <p>
       The following examples show the
       <code class="literal">
        log_filter_dragnet
       </code>
       rules to achieve an
              effect similar to each
       <a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
        <code class="literal">
         log_error_verbosity
        </code>
       </a>
       value
              permitted by the
       <code class="literal">
        log_filter_internal
       </code>
       filter:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          Errors only
                  (
          <code class="literal">
           log_error_verbosity=1
          </code>
          ):
         </p>
         <div class="copytoclipboard-wrapper">
          <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa88074856"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">&gt;</span> <span class="token keyword">ERROR</span> <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span></code></pre>
         </div>
        </li>
        <li class="listitem">
         <p>
          Errors and warnings
                  (
          <code class="literal">
           log_error_verbosity=2
          </code>
          ):
         </p>
         <div class="copytoclipboard-wrapper">
          <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa32155938"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">&gt;</span> WARNING <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span></code></pre>
         </div>
        </li>
        <li class="listitem">
         <p>
          Errors, warnings, and notes
                  (
          <code class="literal">
           log_error_verbosity=3
          </code>
          ):
         </p>
         <div class="copytoclipboard-wrapper">
          <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa35059797"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> prio <span class="token operator">&gt;</span> INFORMATION <span class="token keyword">THEN</span> <span class="token keyword">drop</span><span class="token punctuation">.</span></code></pre>
         </div>
         <p>
          This rule can actually be omitted because there are no
          <code class="literal">
           prio
          </code>
          values greater than
          <code class="literal">
           INFORMATION
          </code>
          , so effectively it
                  drops nothing.
         </p>
        </li>
       </ul>
      </div>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        err_code
       </code>
      </p>
      <p>
       The numeric event error code. In comparisons, the value to
              test can be specified as a symbolic error name or an
              integer literal. Error symbols are recognized only in
              comparisons with the
       <code class="literal">
        err_code
       </code>
       field and
              user-defined fields. These comparisons are equivalent:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30834351"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> ER_ACCESS_DENIED_ERROR <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">IF</span> err_code <span class="token operator">=</span><span class="token operator">=</span> <span class="token number">1045</span> <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        err_symbol
       </code>
      </p>
      <p>
       The event error symbol, as a string (for example,
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_dup_key" target="_top">
        <code class="literal">
         'ER_DUP_KEY'
        </code>
       </a>
       ).
       <code class="literal">
        err_symbol
       </code>
       values are intended more for
              identifying particular lines in log output than for use in
              filter rule comparisons because
       <code class="literal">
        log_filter_dragnet
       </code>
       does not resolve
              comparison values specified as strings to the equivalent
              numeric error code. (For that to occur, an error must be
              specified using its unquoted symbol.)
      </p>
     </li>
    </ul>
   </div>
   <h6>
    <a name="error-log-dragnet-optional-field-references">
    </a>
    Optional Field References
   </h6>
   <p>
    The
    <code class="literal">
     log_filter_dragnet
    </code>
    grammar at
    <a class="xref" href="error-log-rule-based-filtering.html#error-log-dragnet-filtering-language" title="Grammar for log_filter_dragnet Rule Language">
     Grammar for log_filter_dragnet Rule Language
    </a>
    names
          the optional fields that filter rules recognize. For general
          descriptions of these fields, see
    <a class="xref" href="error-log-event-fields.html" title="7.4.2.3 Error Event Fields">
     Section 7.4.2.3, “Error Event Fields”
    </a>
    , with which you are
          assumed to be familiar. The following remarks provide
          additional information only as it pertains specifically to
          optional field references as used within
    <code class="literal">
     log_filter_dragnet
    </code>
    rules.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        label
       </code>
      </p>
      <p>
       The label corresponding to the
       <code class="literal">
        prio
       </code>
       value, as a string. Filter rules can change the label for
              log sinks that support custom labels.
       <code class="literal">
        label
       </code>
       values are intended more for
              identifying particular lines in log output than for use in
              filter rule comparisons because
       <code class="literal">
        log_filter_dragnet
       </code>
       does not resolve
              comparison values specified as strings to the equivalent
              numeric priority.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        source_file
       </code>
      </p>
      <p>
       The source file in which the event occurred, without any
              leading path. For example, to test for the
       <code class="filename">
        sql/gis/distance.cc
       </code>
       file, write the
              comparison like this:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa97396776"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">IF</span> source_file <span class="token operator">=</span><span class="token operator">=</span> <span class="token string">"distance.cc"</span> <span class="token keyword">THEN</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <h6>
    <a name="error-log-dragnet-user-defined-field-references">
    </a>
    User-Defined Field References
   </h6>
   <p>
    Any field name in a
    <code class="literal">
     log_filter_dragnet
    </code>
    filter rule not recognized as a core or optional field name is
          taken to refer to a user-defined field.
   </p>
  </div>
 </div>
 <br/>
</div>
