Package org.logevents.observers
Class SlackLogEventObserver
- java.lang.Object
-
- org.logevents.core.AbstractFilteredLogEventObserver
-
- org.logevents.observers.AbstractBatchingLogEventObserver
-
- org.logevents.observers.AbstractHttpPostJsonLogEventObserver
-
- org.logevents.observers.SlackLogEventObserver
-
- All Implemented Interfaces:
LogEventObserver
public class SlackLogEventObserver extends AbstractHttpPostJsonLogEventObserver
Writes log events as asynchronous batches to Slack. Slack is a great destination for logging as it provides great notification support on mobile and desktop platforms. Requires a Slack Web Hook, which you can create as a Slack Custom Integration.Example configuration:
observer.slack=SlackLogEventObserver observer.slack.slackUrl=https://hooks.slack.com/services/XXXX/XXX/XXX observer.slack.proxy=proxy.example.net:8888 observer.slack.threshold=WARN observer.slack.slackLogEventsFormatter=
SlackLogEventsFormatter
observer.slack.showRepeatsIndividually=false observer.slack.channel=alertChannel observer.slack.username=applicationNode observer.slack.iconEmoji=:ant: observer.slack.cooldownTime=PT10S observer.slack.maximumWaitTime=PT5M observer.slack.idleThreshold=PT5S observer.slack.suppressMarkers=BORING_MARKER observer.slack.requireMarker=MY_MARKER, MY_OTHER_MARKER observer.slack.detailUrl=link to yourLogEventsServlet
observer.slack.packageFilter=sun.www, com.example.uninteresting observer.slack.includedMdcKeys=clientIp observer.slack.markers.MY_MARKER.throttle=PT1M PT10M PT30M observer.slack.markers.MY_MARKER.mdc=userId observer.slack.markers.MY_MARKER.emoji=:rocket:
-
-
Field Summary
-
Fields inherited from class org.logevents.observers.AbstractBatchingLogEventObserver
defaultBatcher, executor, scheduledExecutorService, shutdownHook
-
-
Constructor Summary
Constructors Constructor Description SlackLogEventObserver(URL slackUrl, Optional<String> username, Optional<String> channel)
SlackLogEventObserver(URL slackUrl, SlackLogEventsFormatter formatter)
SlackLogEventObserver(Map<String,String> properties, String prefix)
SlackLogEventObserver(Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SlackLogEventsFormatter
createFormatter(Configuration configuration)
protected SlackLogEventsFormatter
createMarkerFormatter(Configuration configuration, String markerName)
protected LogEventObserver
createMdcBatcher(BatcherFactory batcherFactory, Configuration configuration, String markerName, String mdcKey)
protected Consumer<List<LogEvent>>
createProcessor(Configuration configuration, String markerName)
protected Map<String,Object>
formatBatch(LogEventBatch batch)
Override this method to customize how theLogEventBatch
will be formatted as JSON.protected SlackLogEventsFormatter
setupFormatter(Configuration configuration)
String
toString()
-
Methods inherited from class org.logevents.observers.AbstractHttpPostJsonLogEventObserver
configureProxy, getProxy, getUrl, postJson, processBatch, sendBatch
-
Methods inherited from class org.logevents.observers.AbstractBatchingLogEventObserver
configureBatching, configureMarkers, createBatcher, doLogEvent, getBatcher, getBatcherFactory, getDefaultBatcher, getMarkerBatcher, processBatch
-
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
-
SlackLogEventObserver
public SlackLogEventObserver(Configuration configuration)
-
SlackLogEventObserver
public SlackLogEventObserver(URL slackUrl, Optional<String> username, Optional<String> channel)
-
SlackLogEventObserver
public SlackLogEventObserver(URL slackUrl, SlackLogEventsFormatter formatter)
-
-
Method Detail
-
setupFormatter
protected SlackLogEventsFormatter setupFormatter(Configuration configuration)
-
createFormatter
protected SlackLogEventsFormatter createFormatter(Configuration configuration)
-
createProcessor
protected Consumer<List<LogEvent>> createProcessor(Configuration configuration, String markerName)
- Overrides:
createProcessor
in classAbstractBatchingLogEventObserver
-
createMarkerFormatter
protected SlackLogEventsFormatter createMarkerFormatter(Configuration configuration, String markerName)
-
createMdcBatcher
protected LogEventObserver createMdcBatcher(BatcherFactory batcherFactory, Configuration configuration, String markerName, String mdcKey)
- Overrides:
createMdcBatcher
in classAbstractBatchingLogEventObserver
-
formatBatch
protected Map<String,Object> formatBatch(LogEventBatch batch)
Description copied from class:AbstractHttpPostJsonLogEventObserver
Override this method to customize how theLogEventBatch
will be formatted as JSON.- Specified by:
formatBatch
in classAbstractHttpPostJsonLogEventObserver
-
toString
public String toString()
- Overrides:
toString
in classAbstractHttpPostJsonLogEventObserver
-
-