Class RateLimitingFilter

java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilter
org.elasticsearch.common.logging.RateLimitingFilter
All Implemented Interfaces:
org.apache.logging.log4j.core.Filter, org.apache.logging.log4j.core.LifeCycle, org.apache.logging.log4j.core.LifeCycle2

@Plugin(name="RateLimitingFilter", category="Core", elementType="filter") public class RateLimitingFilter extends org.apache.logging.log4j.core.filter.AbstractFilter
A filter used for throttling deprecation logs. A throttling is based on a combined key which consists of `key` from the logged ESMessage and `x-opaque-id` passed by a user on a HTTP header. This filter works by using a lruKeyCache - a set of keys which prevents a second message with the same key to be logged. The lruKeyCache has a size limited to 128, which when breached will remove the oldest entries.

It is possible to disable use of `x-opaque-id` as a key with setUseXOpaqueId(boolean)

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.logging.log4j.core.filter.AbstractFilter

    org.apache.logging.log4j.core.filter.AbstractFilter.AbstractFilterBuilder<B extends org.apache.logging.log4j.core.filter.AbstractFilter.AbstractFilterBuilder<B>>

    Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.Filter

    org.apache.logging.log4j.core.Filter.Result

    Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle

    org.apache.logging.log4j.core.LifeCycle.State
  • Field Summary

    Fields inherited from class org.apache.logging.log4j.core.filter.AbstractFilter

    onMatch, onMismatch

    Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

    DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER

    Fields inherited from interface org.apache.logging.log4j.core.Filter

    ELEMENT_TYPE, EMPTY_ARRAY
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    RateLimitingFilter(org.apache.logging.log4j.core.Filter.Result onMatch, org.apache.logging.log4j.core.Filter.Result onMismatch)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    createFilter(org.apache.logging.log4j.core.Filter.Result match, org.apache.logging.log4j.core.Filter.Result mismatch)
     
    org.apache.logging.log4j.core.Filter.Result
    filter(org.apache.logging.log4j.core.LogEvent event)
     
    org.apache.logging.log4j.core.Filter.Result
    filter(org.apache.logging.log4j.core.Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message msg, Throwable t)
     
    org.apache.logging.log4j.core.Filter.Result
    filter(org.apache.logging.log4j.message.Message message)
     
    void
    Clears the cache of previously-seen keys.
    void
    setUseXOpaqueId(boolean useXOpaqueId)
     

    Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilter

    equalsImpl, filter, filter, filter, filter, filter, filter, filter, filter, filter, filter, filter, filter, getOnMatch, getOnMismatch, hashCodeImpl, toString

    Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

    getState, getStatusLogger, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.logging.log4j.core.LifeCycle

    getState, initialize, isStarted, isStopped, start, stop
  • Constructor Details

    • RateLimitingFilter

      public RateLimitingFilter()
    • RateLimitingFilter

      public RateLimitingFilter(org.apache.logging.log4j.core.Filter.Result onMatch, org.apache.logging.log4j.core.Filter.Result onMismatch)
  • Method Details

    • reset

      public void reset()
      Clears the cache of previously-seen keys.
    • filter

      public org.apache.logging.log4j.core.Filter.Result filter(org.apache.logging.log4j.message.Message message)
    • filter

      public org.apache.logging.log4j.core.Filter.Result filter(org.apache.logging.log4j.core.LogEvent event)
      Specified by:
      filter in interface org.apache.logging.log4j.core.Filter
      Overrides:
      filter in class org.apache.logging.log4j.core.filter.AbstractFilter
    • filter

      public org.apache.logging.log4j.core.Filter.Result filter(org.apache.logging.log4j.core.Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message msg, Throwable t)
      Specified by:
      filter in interface org.apache.logging.log4j.core.Filter
      Overrides:
      filter in class org.apache.logging.log4j.core.filter.AbstractFilter
    • createFilter

      @PluginFactory public static RateLimitingFilter createFilter(@PluginAttribute("onMatch") org.apache.logging.log4j.core.Filter.Result match, @PluginAttribute("onMismatch") org.apache.logging.log4j.core.Filter.Result mismatch)
    • setUseXOpaqueId

      public void setUseXOpaqueId(boolean useXOpaqueId)