Class WebhookSink
- java.lang.Object
-
- com.floragunn.searchguard.auditlog.sink.AuditLogSink
-
- com.floragunn.searchguard.auditlog.sink.WebhookSink
-
public class WebhookSink extends AuditLogSink
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWebhookSink.WebhookFormat
-
Field Summary
-
Fields inherited from class com.floragunn.searchguard.auditlog.sink.AuditLogSink
fallbackSink, log, settings, settingsPrefix
-
-
Constructor Summary
Constructors Constructor Description WebhookSink(String name, org.elasticsearch.common.settings.Settings settings, String settingsPrefix, Path configPath, AuditLogSink fallbackSink)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected booleandoGet(String url)protected booleandoPost(String url, String payload)booleandoStore(AuditMessage msg)protected StringformatJson(AuditMessage msg)Transforms anAuditMessageto JSON.protected StringformatSlack(AuditMessage msg)Transforms anAuditMessageto Slack format.protected StringformatText(AuditMessage msg)Transforms anAuditMessageto plain text.protected StringformatUrlParameters(AuditMessage msg)Transforms anAuditMessageto a query parameter String.-
Methods inherited from class com.floragunn.searchguard.auditlog.sink.AuditLogSink
equals, getExpandedIndexName, getFallbackSink, getName, getSinkSettings, hashCode, isHandlingBackpressure, store, toString
-
-
-
-
Method Detail
-
doStore
public boolean doStore(AuditMessage msg)
- Specified by:
doStorein classAuditLogSink
-
close
public void close() throws IOException- Overrides:
closein classAuditLogSink- Throws:
IOException
-
formatJson
protected String formatJson(AuditMessage msg)
Transforms anAuditMessageto JSON. By default, all fields are included in the JSON string. This method can be overridden by subclasses if a specific JSON format is needed.- Parameters:
msg- the AuditMessage to transform- Returns:
- the JSON string
-
formatText
protected String formatText(AuditMessage msg)
Transforms anAuditMessageto plain text. This method can be overridden by subclasses if a specific text format is needed.- Parameters:
msg- the AuditMessage to transform- Returns:
- the text string
-
formatSlack
protected String formatSlack(AuditMessage msg)
Transforms anAuditMessageto Slack format. The default implementation returns{ "text": "" } Can be overridden by subclasses if a more specific format is needed.
- Parameters:
msg- the AuditMessage to transform- Returns:
- the Slack formatted JSON string
-
formatUrlParameters
protected String formatUrlParameters(AuditMessage msg)
Transforms anAuditMessageto a query parameter String. Used byWebhookSink.WebhookFormat.URL_PARAMETER_GETand Used byWebhookSink.WebhookFormat.URL_PARAMETER_POST. Can be overridden by subclasses if a specific format is needed.- Parameters:
msg- the AuditMessage to transform- Returns:
- the query parameter string
-
doGet
protected boolean doGet(String url)
-
-