Package org.logevents.observers
Class ElasticsearchLogEventObserver
- java.lang.Object
-
- org.logevents.core.AbstractFilteredLogEventObserver
-
- org.logevents.observers.AbstractBatchingLogEventObserver
-
- org.logevents.observers.ElasticsearchLogEventObserver
-
- All Implemented Interfaces:
LogEventObserver
- Direct Known Subclasses:
HumioLogEventObserver
public class ElasticsearchLogEventObserver extends AbstractBatchingLogEventObserver
Publishes asynchronously to Elasticsearch with the Elasticsearch Index APISample configuration
observer.elastic=ElasticSearchLogEventObserver observer.elastic.elasticsearchUrl=http://localhost:9200 observer.elastic.elasticsearchUrlPath=_bulk observer.elastic.elasticsearchAuthorizationHeader=repositoryId injectApiToken observer.elastic.index=my-test-index observer.elastic.idleThreshold=PT2S observer.elastic.cooldownTime=PT1S observer.elastic.maximumWaitTime=PT30S observer.elastic.suppressMarkers=PERSONAL_DATA observer.elastic.formatter.excludedMdcKeys=secret
Elasticsearch configuration
elasticsearchUrl
should point to where the elasticsearch API lives. It should contain an URI scheme and authority.elasticsearchUrlPath
should point to the http path where the Elasticsearch Bulk API lives.
Authorization
The configurable
elasticsearchAuthorizationHeader
is the value the client will include as Authorization header when communicating withelasticsearchUrl
. It is not to be confused by Basic authentication. If you need basic authentication you need to remember to provide its configuration value as 'Basic base64encodedValueHere
'.- See Also:
- RFC3986 #section3 about URI syntax
-
-
Field Summary
-
Fields inherited from class org.logevents.observers.AbstractBatchingLogEventObserver
defaultBatcher, executor, scheduledExecutorService, shutdownHook
-
-
Constructor Summary
Constructors Constructor Description ElasticsearchLogEventObserver(Map<String,String> properties, String prefix)
ElasticsearchLogEventObserver(Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configureProxy(Configuration configuration)
Map<String,Object>
formatMessage(LogEvent event)
protected String
getDefaultPath()
String
getIndex()
Map<String,Object>
getIndexHeader()
URL
getUrl()
protected List<String>
parseBulkApiResponse(Map<String,Object> response)
protected void
processBatch(LogEventBatch batch)
-
Methods inherited from class org.logevents.observers.AbstractBatchingLogEventObserver
configureBatching, configureMarkers, createBatcher, createMdcBatcher, createProcessor, doLogEvent, getBatcher, getBatcherFactory, getDefaultBatcher, getMarkerBatcher, processBatch, toString
-
Methods inherited from class org.logevents.core.AbstractFilteredLogEventObserver
configureFilter, filteredOn, getCondition, getThreshold, isEnabled, logEvent, setCondition, setFilter, setThreshold, shouldLogEvent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.logevents.LogEventObserver
isEnabled, stream, toList
-
-
-
-
Constructor Detail
-
ElasticsearchLogEventObserver
public ElasticsearchLogEventObserver(Map<String,String> properties, String prefix)
-
ElasticsearchLogEventObserver
public ElasticsearchLogEventObserver(Configuration configuration)
-
-
Method Detail
-
getDefaultPath
protected String getDefaultPath()
-
configureProxy
public void configureProxy(Configuration configuration)
-
processBatch
protected void processBatch(LogEventBatch batch)
- Specified by:
processBatch
in classAbstractBatchingLogEventObserver
-
getIndex
public String getIndex()
-
parseBulkApiResponse
protected List<String> parseBulkApiResponse(Map<String,Object> response) throws IOException
- Throws:
IOException
-
getUrl
public URL getUrl()
-
-