public abstract class AuditLoggerPlugin extends Object implements Closeable, Runnable, SolrInfoBean, SolrMetricProducer
Modifier and Type | Class and Description |
---|---|
static interface |
AuditLoggerPlugin.AuditEventFormatter
Interface for formatting the event
|
static class |
AuditLoggerPlugin.JSONAuditEventFormatter
Event formatter that returns event as JSON string
|
static interface |
AuditLoggerPlugin.MuteRule |
SolrInfoBean.Category, SolrInfoBean.Group
Modifier and Type | Field and Description |
---|---|
protected List<String> |
eventTypes |
protected AuditLoggerPlugin.AuditEventFormatter |
formatter |
protected SolrMetricManager |
metricManager |
protected com.codahale.metrics.Meter |
numErrors |
protected com.codahale.metrics.Meter |
numLogged |
protected com.codahale.metrics.Meter |
numLost |
protected com.codahale.metrics.Timer |
queuedTime |
protected String |
registryName |
protected com.codahale.metrics.Timer |
requestTimes |
protected com.codahale.metrics.Counter |
totalTime |
Constructor and Description |
---|
AuditLoggerPlugin() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
audit(AuditEvent event)
This is the method that each Audit plugin has to implement to do the actual logging.
|
protected void |
auditAsync(AuditEvent event)
Enqueues an
AuditEvent to a queue and returns immediately. |
void |
close()
Waits 30s for async queue to drain, then closes executor threads.
|
void |
doAudit(AuditEvent event)
Called by the framework, and takes care of metrics tracking and to dispatch
to either synchronous or async logging.
|
SolrInfoBean.Category |
getCategory()
Category of this component
|
String |
getDescription()
Simple one or two line description
|
Set<String> |
getMetricNames()
Modifiable set of metric names that this component reports (default is null,
which means none).
|
com.codahale.metrics.MetricRegistry |
getMetricRegistry()
An instance of
MetricRegistry that this component uses for metrics reporting
(default is null, which means no registry). |
String |
getName()
Simple common usage name, e.g.
|
void |
init(Map<String,Object> pluginConfig)
Initialize the plugin from security.json.
|
void |
initializeMetrics(SolrMetricManager manager,
String registryName,
String tag,
String scope)
Initializes metrics specific to this producer
|
void |
run()
Pick next event from async queue and call
audit(AuditEvent) |
void |
setFormatter(AuditLoggerPlugin.AuditEventFormatter formatter) |
boolean |
shouldLog(AuditEvent.EventType eventType)
Checks whether this event type should be logged based on "eventTypes" config parameter.
|
protected boolean |
shouldMute(AuditEvent event)
Returns true if any of the configured mute rules matches.
|
protected void |
waitForQueueToDrain(int timeoutSeconds)
Blocks until the async event queue is drained
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMetricsSnapshot, registerMetricName
protected AuditLoggerPlugin.AuditEventFormatter formatter
protected String registryName
protected SolrMetricManager metricManager
protected com.codahale.metrics.Meter numErrors
protected com.codahale.metrics.Meter numLost
protected com.codahale.metrics.Meter numLogged
protected com.codahale.metrics.Timer requestTimes
protected com.codahale.metrics.Timer queuedTime
protected com.codahale.metrics.Counter totalTime
public void init(Map<String,Object> pluginConfig)
pluginConfig
- the config for the pluginprotected abstract void audit(AuditEvent event)
event
- the audit eventpublic final void doAudit(AuditEvent event)
protected boolean shouldMute(AuditEvent event)
event
- the audit eventprotected final void auditAsync(AuditEvent event)
AuditEvent
to a queue and returns immediately.
A background thread will pull events from this queue and call audit(AuditEvent)
event
- the audit eventpublic void run()
audit(AuditEvent)
public boolean shouldLog(AuditEvent.EventType eventType)
eventType
- the event type to considerpublic void setFormatter(AuditLoggerPlugin.AuditEventFormatter formatter)
public void initializeMetrics(SolrMetricManager manager, String registryName, String tag, String scope)
SolrMetricProducer
initializeMetrics
in interface SolrMetricProducer
manager
- an instance of SolrMetricManager
registryName
- registry name where metrics are registeredtag
- a symbolic tag that represents this instance of the producer,
or a group of related instances that have the same life-cycle. This tag is
used when managing life-cycle of some metrics and is set when
SolrMetricProducer.initializeMetrics(SolrMetricManager, String, String, String)
is called.scope
- scope of the metrics (eg. handler name) to separate metrics ofpublic String getName()
SolrInfoBean
getName
in interface SolrInfoBean
public String getDescription()
SolrInfoBean
getDescription
in interface SolrInfoBean
public SolrInfoBean.Category getCategory()
SolrInfoBean
getCategory
in interface SolrInfoBean
public Set<String> getMetricNames()
SolrInfoBean
SolrInfoBean.registerMetricName(String)
to capture what metrics names are reported from this component.
NOTE: this set has to allow iteration under modifications.
getMetricNames
in interface SolrInfoBean
public com.codahale.metrics.MetricRegistry getMetricRegistry()
SolrInfoBean
MetricRegistry
that this component uses for metrics reporting
(default is null, which means no registry).getMetricRegistry
in interface SolrInfoBean
public void close() throws IOException
super.close()
or waitForQueueToDrain(int)
before shutting itself down to make sure they can complete logging events in the queue.close
in interface Closeable
close
in interface AutoCloseable
IOException
protected void waitForQueueToDrain(int timeoutSeconds)
timeoutSeconds
- number of seconds to wait for queue to drainCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.