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
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 Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for formatting the eventstatic classEvent formatter that returns event as JSON stringstatic interfaceNested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuditLoggerPlugin.AuditEventFormatterprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongTimerprotected SolrMetricsContextFields inherited from interface org.apache.solr.metrics.SolrMetricProducer
CATEGORY_ATTR, HANDLER_ATTR, NAME_ATTR, OPERATION_ATTR, PLUGIN_NAME_ATTR, RESULT_ATTR, TYPE_ATTR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaudit(AuditEvent event) This is the method that each Audit plugin has to implement to do the actual logging.protected final voidauditAsync(AuditEvent event) Enqueues anAuditEventto a queue and returns immediately.voidclose()Waits 30s for async queue to drain, then closes executor threads.final voiddoAudit(AuditEvent event) Called by the framework, and takes care of metrics tracking and to dispatch to either synchronous or async logging.Category of this componentSimple one or two line descriptiongetName()Simple common usage name, e.g.Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, Attributes)to ensure proper cleanup of metrics at the end of the life-cycle of this component.voidInitialize the plugin from security.json.voidinitializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Implementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/componentvoidrun()Pick next event from async queue and callaudit(AuditEvent)voidbooleanshouldLog(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 Details
-
formatter
-
solrMetricsContext
-
numLogged
-
numErrors
-
numLost
-
requestTimes
-
eventTypes
-
-
Constructor Details
-
AuditLoggerPlugin
public AuditLoggerPlugin()
-
-
Method Details
-
init
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
-
audit
This is the method that each Audit plugin has to implement to do the actual logging.- Parameters:
event- the audit event
-
doAudit
Called by the framework, and takes care of metrics tracking and to dispatch to either synchronous or async logging. -
shouldMute
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
-
auditAsync
Enqueues anAuditEventto a queue and returns immediately. A background thread will pull events from this queue and callaudit(AuditEvent)- Parameters:
event- the audit event
-
run
public void run()Pick next event from async queue and callaudit(AuditEvent) -
shouldLog
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
-
setFormatter
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Description copied from interface:SolrMetricProducerImplementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/component- Specified by:
initializeMetricsin interfaceSolrMetricProducer- Parameters:
parentContext- The registry that the component will initialize metrics toattributes- Base set of attributes that will be bound to all metrics for that component
-
getName
Description copied from interface:SolrInfoBeanSimple common usage name, e.g. BasicQueryHandler, or fully qualified class name.- Specified by:
getNamein interfaceSolrInfoBean
-
getDescription
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean
-
getCategory
Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
getCategoryin interfaceSolrInfoBean
-
getSolrMetricsContext
Description copied from interface:SolrMetricProducerImplementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, Attributes)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 interfaceSolrMetricProducer
-
close
Waits 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 interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSolrMetricProducer- Throws:
IOException
-
waitForQueueToDrain
protected void waitForQueueToDrain(int timeoutSeconds) Blocks until the async event queue is drained- Parameters:
timeoutSeconds- number of seconds to wait for queue to drain
-