Package org.apache.solr.security
Class AuditLoggerPlugin
- java.lang.Object
- 
- org.apache.solr.security.AuditLoggerPlugin
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Runnable,- SolrInfoBean,- SolrMetricProducer
 - Direct Known Subclasses:
- MultiDestinationAuditLogger,- SolrLogAuditLoggerPlugin
 
 public abstract class AuditLoggerPlugin extends Object implements Closeable, Runnable, SolrInfoBean Base class for Audit logger plugins. This interface may change in next release and is marked experimental- Since:
- 8.1.0
- WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceAuditLoggerPlugin.AuditEventFormatterInterface for formatting the eventstatic classAuditLoggerPlugin.JSONAuditEventFormatterEvent formatter that returns event as JSON stringstatic interfaceAuditLoggerPlugin.MuteRule- 
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBeanSolrInfoBean.Category, SolrInfoBean.Group
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected List<String>eventTypesprotected AuditLoggerPlugin.AuditEventFormatterformatterprotected com.codahale.metrics.MeternumErrorsprotected com.codahale.metrics.MeternumLoggedprotected com.codahale.metrics.MeternumLostprotected com.codahale.metrics.TimerqueuedTimeprotected com.codahale.metrics.TimerrequestTimesprotected SolrMetricsContextsolrMetricsContextprotected com.codahale.metrics.CountertotalTime
 - 
Constructor SummaryConstructors Constructor Description AuditLoggerPlugin()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaudit(AuditEvent event)This is the method that each Audit plugin has to implement to do the actual logging.protected voidauditAsync(AuditEvent event)Enqueues anAuditEventto a queue and returns immediately.voidclose()Waits 30s for async queue to drain, then closes executor threads.voiddoAudit(AuditEvent event)Called by the framework, and takes care of metrics tracking and to dispatch to either synchronous or async logging.SolrInfoBean.CategorygetCategory()Category of this componentStringgetDescription()Simple one or two line descriptionStringgetName()Simple common usage name, e.g.SolrMetricsContextgetSolrMetricsContext()Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)to ensure proper cleanup of metrics at the end of the life-cycle of this component.voidinit(Map<String,Object> pluginConfig)Initialize the plugin from security.json.voidinitializeMetrics(SolrMetricsContext parentContext, String scope)Initialize metrics specific to this producer.voidrun()Pick next event from async queue and callaudit(AuditEvent)voidsetFormatter(AuditLoggerPlugin.AuditEventFormatter formatter)booleanshouldLog(AuditEvent.EventType eventType)Checks whether this event type should be logged based on "eventTypes" config parameter.protected booleanshouldMute(AuditEvent event)Returns true if any of the configured mute rules matches.protected voidwaitForQueueToDrain(int timeoutSeconds)Blocks until the async event queue is drained
 
- 
- 
- 
Field Detail- 
formatterprotected AuditLoggerPlugin.AuditEventFormatter formatter 
 - 
solrMetricsContextprotected SolrMetricsContext solrMetricsContext 
 - 
numErrorsprotected com.codahale.metrics.Meter numErrors 
 - 
numLostprotected com.codahale.metrics.Meter numLost 
 - 
numLoggedprotected com.codahale.metrics.Meter numLogged 
 - 
requestTimesprotected com.codahale.metrics.Timer requestTimes 
 - 
queuedTimeprotected com.codahale.metrics.Timer queuedTime 
 - 
totalTimeprotected com.codahale.metrics.Counter totalTime 
 
- 
 - 
Method Detail- 
initpublic void init(Map<String,Object> pluginConfig) Initialize the plugin from security.json. This method removes parameters from config object after consuming, so subclasses can check for config errors.- Parameters:
- pluginConfig- the config for the plugin
 
 - 
auditprotected abstract void audit(AuditEvent event) This is the method that each Audit plugin has to implement to do the actual logging.- Parameters:
- event- the audit event
 
 - 
doAuditpublic final void doAudit(AuditEvent event) Called by the framework, and takes care of metrics tracking and to dispatch to either synchronous or async logging.
 - 
shouldMuteprotected boolean shouldMute(AuditEvent event) Returns true if any of the configured mute rules matches. The inner lists are ORed, while rules inside inner lists are ANDed- Parameters:
- event- the audit event
 
 - 
auditAsyncprotected final void auditAsync(AuditEvent event) Enqueues anAuditEventto a queue and returns immediately. A background thread will pull events from this queue and callaudit(AuditEvent)- Parameters:
- event- the audit event
 
 - 
runpublic void run() Pick next event from async queue and callaudit(AuditEvent)
 - 
shouldLogpublic boolean shouldLog(AuditEvent.EventType eventType) Checks whether this event type should be logged based on "eventTypes" config parameter.- Parameters:
- eventType- the event type to consider
- Returns:
- true if this event type should be logged
 
 - 
setFormatterpublic void setFormatter(AuditLoggerPlugin.AuditEventFormatter formatter) 
 - 
initializeMetricspublic void initializeMetrics(SolrMetricsContext parentContext, String scope) Description copied from interface:SolrMetricProducerInitialize metrics specific to this producer.- Specified by:
- initializeMetricsin interface- SolrMetricProducer
- Parameters:
- parentContext- parent metrics context. If this component has the same life-cycle as the parent it can simply use the parent context, otherwise it should obtain a child context using- SolrMetricsContext.getChildContext(Object)passing- thisas the child object.
- scope- component scope
 
 - 
getNamepublic String getName() Description copied from interface:SolrInfoBeanSimple common usage name, e.g. BasicQueryHandler, or fully qualified class name.- Specified by:
- getNamein interface- SolrInfoBean
 
 - 
getDescriptionpublic String getDescription() Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
- getDescriptionin interface- SolrInfoBean
 
 - 
getCategorypublic SolrInfoBean.Category getCategory() Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
- getCategoryin interface- SolrInfoBean
 
 - 
getSolrMetricsContextpublic SolrMetricsContext getSolrMetricsContext() Description copied from interface:SolrMetricProducerImplementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)to ensure proper cleanup of metrics at the end of the life-cycle of this component. This should be the child context if one was created, or null if the parent context was used.- Specified by:
- getSolrMetricsContextin interface- SolrMetricProducer
 
 - 
closepublic void close() throws IOExceptionWaits 30s for async queue to drain, then closes executor threads. Subclasses should either callsuper.close()orwaitForQueueToDrain(int)before shutting itself down to make sure they can complete logging events in the queue.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- SolrMetricProducer
- Throws:
- IOException
 
 - 
waitForQueueToDrainprotected void waitForQueueToDrain(int timeoutSeconds) Blocks until the async event queue is drained- Parameters:
- timeoutSeconds- number of seconds to wait for queue to drain
 
 
- 
 
-