Search in sources :

Example 66 with RawMessage

use of org.graylog2.plugin.journal.RawMessage in project graylog2-server by Graylog2.

the class CEFCodec method decodeCEF.

protected Message decodeCEF(@Nonnull RawMessage rawMessage, String s) {
    try {
        final MappedMessage cef = new MappedMessage(parser.parse(s, timezone.toTimeZone(), locale), useFullNames);
        // Build standard message.
        Message result = new Message(buildMessageSummary(cef), decideSource(cef, rawMessage), new DateTime(cef.timestamp()));
        // Add all extensions.
        result.addFields(cef.mappedExtensions());
        // Add standard CEF fields.
        result.addField("device_vendor", cef.deviceVendor());
        result.addField("device_product", cef.deviceProduct());
        result.addField("device_version", cef.deviceVersion());
        result.addField("event_class_id", cef.deviceEventClassId());
        result.addField("name", cef.name());
        result.addField("severity", cef.severity());
        return result;
    } catch (Exception e) {
        throw new RuntimeException("Could not decode CEF message.", e);
    }
}
Also used : MappedMessage(org.graylog.plugins.cef.parser.MappedMessage) RawMessage(org.graylog2.plugin.journal.RawMessage) Message(org.graylog2.plugin.Message) MappedMessage(org.graylog.plugins.cef.parser.MappedMessage) DateTime(org.joda.time.DateTime)

Aggregations

RawMessage (org.graylog2.plugin.journal.RawMessage)59 Test (org.junit.Test)35 Message (org.graylog2.plugin.Message)23 InetSocketAddress (java.net.InetSocketAddress)13 IOException (java.io.IOException)7 Nullable (javax.annotation.Nullable)7 MappedMessage (org.graylog.plugins.cef.parser.MappedMessage)6 ResolvableInetSocketAddress (org.graylog2.plugin.ResolvableInetSocketAddress)6 DateTime (org.joda.time.DateTime)5 Configuration (org.graylog2.plugin.configuration.Configuration)4 ByteBuf (io.netty.buffer.ByteBuf)3 URL (java.net.URL)3 ZonedDateTime (java.time.ZonedDateTime)3 Timer (com.codahale.metrics.Timer)2 List (java.util.List)2 Map (java.util.Map)2 Properties (java.util.Properties)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 NotFoundException (javax.ws.rs.NotFoundException)2 DocumentNotFoundException (org.graylog2.indexer.messages.DocumentNotFoundException)2