Class AbstractFormattedTimestampJsonProvider<Event extends DeferredProcessingAware,FieldNames extends LogstashCommonFieldNames>

All Implemented Interfaces:
ContextAware, FieldNamesAware<FieldNames>, JsonProvider<Event>
Direct Known Subclasses:
AccessEventFormattedTimestampJsonProvider, FormattedTimestampJsonProvider, LoggingEventFormattedTimestampJsonProvider

public abstract class AbstractFormattedTimestampJsonProvider<Event extends DeferredProcessingAware,FieldNames extends LogstashCommonFieldNames> extends AbstractFieldJsonProvider<Event> implements FieldNamesAware<FieldNames>
Writes the timestamp field as either:
  • Field Details

    • FIELD_TIMESTAMP

      public static final String FIELD_TIMESTAMP
      See Also:
    • UNIX_TIMESTAMP_AS_NUMBER

      public static final String UNIX_TIMESTAMP_AS_NUMBER
      Setting the pattern as this value will make it so that the timestamp is written as a number value of the milliseconds since unix epoch.
      See Also:
    • UNIX_TIMESTAMP_AS_STRING

      public static final String UNIX_TIMESTAMP_AS_STRING
      Setting the pattern as this value will make it so that the timestamp is written as a string value representing the number of milliseconds since unix epoch
      See Also:
    • DEFAULT_TIMEZONE_KEYWORD

      public static final String DEFAULT_TIMEZONE_KEYWORD
      Keyword used by setTimeZone(String) to denote the system default time zone.
      See Also:
  • Constructor Details

    • AbstractFormattedTimestampJsonProvider

      public AbstractFormattedTimestampJsonProvider()
  • Method Details

    • setFieldNames

      public void setFieldNames(FieldNames fieldNames)
      Specified by:
      setFieldNames in interface FieldNamesAware<Event extends DeferredProcessingAware>
    • writeTo

      public void writeTo(JsonGenerator generator, Event event) throws IOException
      Description copied from interface: JsonProvider
      Writes information about the event, to the given generator.

      When called, the generator is assumed to be within a JSON object context (i.e. this provider should write fields and their values to the generator). Upon return, the generator should be within the same JSON object context.

      Specified by:
      writeTo in interface JsonProvider<Event extends DeferredProcessingAware>
      Parameters:
      generator - the JsonGenerator to produce JSON content
      event - the event to convert into JSON
      Throws:
      IOException - if an I/O error occurs
    • getFormattedTimestamp

      protected String getFormattedTimestamp(Event event)
    • getTimestampAsInstant

      protected abstract Instant getTimestampAsInstant(Event event)
    • getPattern

      public String getPattern()
    • setPattern

      public void setPattern(String pattern)
    • getTimeZone

      public String getTimeZone()
      Get the time zone used to write the timestamp.
      Returns:
      the time zone used to write the timestamp
    • setTimeZone

      public void setTimeZone(String timeZone)
      Set the timezone for which to write the timestamp. Only applicable if the pattern is not "[UNIX_TIMESTAMP_AS_NUMBER]" or "[UNIX_TIMESTAMP_AS_STRING]".

      The value of the timeZone can be any string accepted by java's TimeZone.getTimeZone(String) method. For example "America/Los_Angeles" or "GMT+10".

      Use a blank string, null or the value "[DEFAULT]" to use the default TimeZone of the system.

      Parameters:
      timeZone - the textual representation of the desired time zone
      Throws:
      IllegalArgumentException - if the input string is not a valid TimeZone representation