Package org.graylog2.plugin
Class Message
java.lang.Object
org.graylog2.plugin.Message
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Deprecated.static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
Will be set to the accounted message size in bytes.static final String
This is the message ID.static final String
Can be set to indicate a message processing error.static final String
Will be set to the message processing time after all message processors have been run.static final String
Will be set to the message receive time at the input.static final String
Will be set to the hostname of the source node that sent a message.static final String
Will be set to the IP address of the source node that sent a message.static final String
Will be set to the socket port of the source node that sent a message.static final String
Can be set to the collector ID that sent a message.static final String
Deprecated.This was used in the legacy collector/sidecar system and contained the database ID of the collector input.static final String
Will be set to the ID of the input that received the message.static final String
Will be set to the ID of the node that received the message.static final String
Deprecated.This was used with the now removed radio system and contained the ID of a radio node.static final String
Deprecated.This was used with the now removed radio system and contained the input ID of a radio node.static final String
The "_id" is used as document ID to address the document in Elasticsearch.static final String
static final String
static final String
static final String
static final String
static final com.google.common.collect.ImmutableSet<String>
Deprecated.static final String
Graylog is writing internal metadata to messages using this field prefix.static final com.google.common.collect.ImmutableSet<String>
static final com.google.common.collect.ImmutableSet<String>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDoubleFields
(Map<String, Double> fields) Deprecated.void
void
void
addLongFields
(Map<String, Long> fields) Deprecated.void
addProcessingError
(Message.ProcessingError processingError) Appends another processing error.void
Assign the given stream to this message.void
addStreams
(Iterable<Stream> newStreams) Assign all of the streams to this message.void
addStringFields
(Map<String, String> fields) Deprecated.static String
void
<T> T
getFieldAs
(Class<T> T, String key) int
boolean
getId()
Returns the id to address the document in Elasticsearch.Return the index sets for this message based on the assigned streams.boolean
Deprecated.long
Deprecated.UsegetMessageQueueId()
instead.Returns the id to address the document in Elasticsearch.getMetadataValue
(String key) Get the metadata value for the specified key.getMetadataValue
(String key, Object defaultValue) Get the metadata value for the specified key.org.joda.time.DateTime
org.joda.time.DateTime
int
long
getSize()
Get the streams this message is currently routed to.org.joda.time.DateTime
Deprecated.boolean
boolean
boolean
iterator()
Returns a list of submitted processing errorsvoid
recordCounter
(ServerStatus serverStatus, String name, int counter) void
recordTiming
(ServerStatus serverStatus, String name, long elapsedNanos) void
removeField
(String key) void
removeMetadata
(String key) Remove the metadata value for the specified key.boolean
removeStream
(Stream stream) Remove the stream assignment from this message.void
setFilterOut
(boolean filterOut) void
setJournalOffset
(long journalOffset) void
setMessageQueueId
(Object messageQueueId) void
setMetadata
(String key, Object value) Store the specified metadata value within the message's internal metadata map.void
setProcessingTime
(org.joda.time.DateTime processingTime) void
setReceiveTime
(org.joda.time.DateTime receiveTime) void
setSequenceNr
(int sequenceNr) void
void
setSourceInputId
(String sourceInputId) void
setStreams
(List<Stream> streams) Deprecated.boolean
Guides the failure handling framework when deciding whether this particular message should be accepted for the further failure processing.toElasticSearchObject
(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.codahale.metrics.Meter invalidTimestampMeter) toString()
static boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
FIELD_ID
The "_id" is used as document ID to address the document in Elasticsearch. TODO: We might want to use the "gl2_message_id" for this in the future to reduce storage and avoid having basically two different message IDs. To do that we have to check if switching to a different ID format breaks anything with regard to expectations in other code and existing data in Elasticsearch.- See Also:
-
FIELD_MESSAGE
- See Also:
-
FIELD_FULL_MESSAGE
- See Also:
-
FIELD_SOURCE
- See Also:
-
FIELD_TIMESTAMP
- See Also:
-
FIELD_LEVEL
- See Also:
-
FIELD_STREAMS
- See Also:
-
INTERNAL_FIELD_PREFIX
Graylog is writing internal metadata to messages using this field prefix. Users must not use this prefix for custom message fields.- See Also:
-
FIELD_GL2_ACCOUNTED_MESSAGE_SIZE
Will be set to the accounted message size in bytes.- See Also:
-
FIELD_GL2_MESSAGE_ID
This is the message ID. It will be set to aULID
during processing. Attention: This is currently NOT the "_id" field which is used as ID for the document in Elasticsearch!Implementation notes
We are not using the UUID in "_id" for this field because of the following reasons:- Using ULIDs results in shorter IDs (26 characters for ULID vs 36 for UUID) and thus reduced storage usage
- They are guaranteed to be lexicographically sortable (UUIDs are only lexicographically sortable when time-based ones are used)
- See Also:
-
FIELD_GL2_PROCESSING_ERROR
Can be set to indicate a message processing error. (e.g. set by the pipeline interpreter when an error occurs)- See Also:
-
FIELD_GL2_PROCESSING_TIMESTAMP
Will be set to the message processing time after all message processors have been run. TODO: To be done in Graylog 3.2- See Also:
-
FIELD_GL2_RECEIVE_TIMESTAMP
Will be set to the message receive time at the input. TODO: To be done in Graylog 3.2- See Also:
-
FIELD_GL2_REMOTE_HOSTNAME
Will be set to the hostname of the source node that sent a message. (if reverse lookup is enabled)- See Also:
-
FIELD_GL2_REMOTE_IP
Will be set to the IP address of the source node that sent a message.- See Also:
-
FIELD_GL2_REMOTE_PORT
Will be set to the socket port of the source node that sent a message.- See Also:
-
FIELD_GL2_SOURCE_COLLECTOR
Can be set to the collector ID that sent a message. (e.g. used in the beats codec)- See Also:
-
FIELD_GL2_SOURCE_COLLECTOR_INPUT
Deprecated.This was used in the legacy collector/sidecar system and contained the database ID of the collector input.- See Also:
-
FIELD_GL2_SOURCE_INPUT
Will be set to the ID of the input that received the message.- See Also:
-
FIELD_GL2_SOURCE_NODE
Will be set to the ID of the node that received the message.- See Also:
-
FIELD_GL2_SOURCE_RADIO
Deprecated.This was used with the now removed radio system and contained the ID of a radio node. TODO: Due to be removed in Graylog 3.x- See Also:
-
FIELD_GL2_SOURCE_RADIO_INPUT
Deprecated.This was used with the now removed radio system and contained the input ID of a radio node. TODO: Due to be removed in Graylog 3.x- See Also:
-
RESERVED_SETTABLE_FIELDS
-
RESERVED_FIELDS
-
FILTERED_FIELDS
-
ID_FUNCTION
Deprecated.
-
-
Constructor Details
-
Message
-
Message
-
-
Method Details
-
isComplete
public boolean isComplete() -
getValidationErrors
Deprecated. -
getId
Description copied from interface:Indexable
Returns the id to address the document in Elasticsearch. Depending on the implementation this might return aUUID
orULID
This method should only be used where backwards compatibility is needed. Newer code should useIndexable.getMessageId()
instead. -
getMessageId
Description copied from interface:Indexable
Returns the id to address the document in Elasticsearch. The message id is represented as aULID
- Specified by:
getMessageId
in interfaceIndexable
-
getTimestamp
public org.joda.time.DateTime getTimestamp()- Specified by:
getTimestamp
in interfaceIndexable
-
toElasticSearchObject
public Map<String,Object> toElasticSearchObject(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Nonnull com.codahale.metrics.Meter invalidTimestampMeter) - Specified by:
toElasticSearchObject
in interfaceIndexable
-
ensureValidTimestamp
public void ensureValidTimestamp() -
toString
-
toDumpString
-
getMessage
-
getSource
-
setSource
-
addField
-
getSize
public long getSize() -
validKey
-
cleanKey
-
addFields
-
addStringFields
Deprecated. -
addLongFields
Deprecated. -
addDoubleFields
Deprecated. -
removeField
-
getFieldAs
- Throws:
ClassCastException
-
getField
-
getFields
-
getFieldsEntries
-
getFieldCount
public int getFieldCount() -
hasField
-
getFieldNames
-
setStreams
Deprecated. -
getStreams
Get the streams this message is currently routed to.- Returns:
- an immutable copy of the current set of assigned streams, empty if no streams have been assigned
-
addStream
Assign the given stream to this message.- Parameters:
stream
- the stream to route this message into
-
addStreams
Assign all of the streams to this message.- Parameters:
newStreams
- an iterable of Stream objects
-
removeStream
Remove the stream assignment from this message.- Parameters:
stream
- the stream assignment to remove this message from- Returns:
- true if this message was assigned to the stream
-
getIndexSets
Return the index sets for this message based on the assigned streams.- Returns:
- index sets
-
getStreamIds
-
setFilterOut
public void setFilterOut(boolean filterOut) -
getFilterOut
public boolean getFilterOut() -
setSourceInputId
-
getSourceInputId
-
getIsSourceInetAddress
Deprecated. -
getInetAddress
-
setJournalOffset
public void setJournalOffset(long journalOffset) -
getJournalOffset
Deprecated.UsegetMessageQueueId()
instead. -
setMessageQueueId
-
setSequenceNr
public void setSequenceNr(int sequenceNr) -
getSequenceNr
public int getSequenceNr() -
getMessageQueueId
-
getReceiveTime
@Nullable public org.joda.time.DateTime getReceiveTime()- Specified by:
getReceiveTime
in interfaceIndexable
-
setReceiveTime
public void setReceiveTime(org.joda.time.DateTime receiveTime) -
getProcessingTime
@Nullable public org.joda.time.DateTime getProcessingTime() -
setProcessingTime
public void setProcessingTime(org.joda.time.DateTime processingTime) -
recordTiming
-
recordCounter
-
recordingsAsString
-
hasRecordings
public boolean hasRecordings() -
addProcessingError
Appends another processing error.- Parameters:
processingError
- another processing error to be appended. Must not be null.
-
processingErrors
Returns a list of submitted processing errors -
iterator
-
supportsFailureHandling
public boolean supportsFailureHandling()Description copied from interface:Indexable
Guides the failure handling framework when deciding whether this particular message should be accepted for the further failure processing. By default disabled for all messages.- Specified by:
supportsFailureHandling
in interfaceIndexable
-
setMetadata
Store the specified metadata value within the message's internal metadata map.- Parameters:
key
- A globally unique string key identifier for the metadata value.value
- The metadata object value.
-
getMetadataValue
Get the metadata value for the specified key.- Parameters:
key
- The string key for the metadata entry.
-
getMetadataValue
Get the metadata value for the specified key. If not present, then return the default value.- Parameters:
key
- The string key for the metadata entry.
-
removeMetadata
Remove the metadata value for the specified key.- Parameters:
key
- The string key for the metadata entry.
-