Does anyone have a working example of a pipeline rule to extract Exchange 2016 message tracking logs?
I’m currently shipping the logs with filebeat and processing them with a rule similiar to the rule below. But this breaks when a , is in the subject. Is it possible to do a pipeline rule with a csv extractor or is GROK the preferred way? I’ve looked around but haven’t found much. Thinking someone must have a good way to do this with filebeat and a pipeline rule.
rule "type ex-msg-trk-transport"
when
has_field("type") && to_string($message.type) == "ex-msg-trk-transport"
then
// grok the message field
let message_field = to_string($message.message);
let action = grok(pattern: "(%{TIMESTAMP_ISO8601:date-time})?,(%{IPORHOST:client-ip})?,(%{IPORHOST:client-hostname})?,(%{IPORHOST:server-ip})?,(%{IPORHOST:server-hostname})?,(?<source-context>[^,]*)?,(?<connector-id>[^,]*)?,(%{WORD:source-component})?,(%{WORD:event-id})?,(%{NUMBER:internal-message-id})?,(?<message-id>[^,]*)?,(?<network-message-id>[^,]*)?,(?<recipient-address>[^,]*)?,(?<recipient-status>[^,]*)?,(%{NUMBER:total-bytes})?,(%{NUMBER:recipient-count})?,(?<related-recipient-address>[^,]*)?,(?<reference>[^,]*)?,(?<message-subject>[^,]*)?,(?<sender-address>[^,]*)?,(?<return-path>[^,]*)?,(?<message-info>[^,]*)?,(?<directionality>[^,]*)?,(?<tenant-id>[^,]*)?,(?<original-client-ip>[^,]*)?,(?<original-server-ip>[^,]*)?,(?<custom-data>[^,]*)?,(?<transport-traffic-type>[^,]*)?,(?<log-id>[^,]*)?,(?<schema-version>[^,]*)?", value: message_field, only_named_captures: true);
set_fields(action);
end
This would work sometimes, but not always. Depending on if the logs put “” around the subject.
rule "type ex-msg-trk-transport"
when
has_field("type") && to_string($message.type) == "ex-msg-trk-transport"
then
// grok the message field
let message_field = to_string($message.message);
let action = grok(pattern: "(%{TIMESTAMP_ISO8601:date-time})?,(%{IPORHOST:client-ip})?,(%{IPORHOST:client-hostname})?,(%{IPORHOST:server-ip})?,(%{IPORHOST:server-hostname})?,(?<source-context>[^,]*)?,(?<connector-id>[^,]*)?,(%{WORD:source-component})?,(%{WORD:event-id})?,(%{NUMBER:internal-message-id})?,(?<message-id>[^,]*)?,(?<network-message-id>[^,]*)?,(?<recipient-address>[^,]*)?,(?<recipient-status>[^,]*)?,(%{NUMBER:total-bytes})?,(%{NUMBER:recipient-count})?,(?<related-recipient-address>[^,]*)?,(?<reference>[^,]*)?,\"(%{GREEDYDATA:message-subject})?\",(?<sender-address>[^,]*)?,(?<return-path>[^,]*)?,(?<message-info>[^,]*)?,(?<directionality>[^,]*)?,(?<tenant-id>[^,]*)?,(?<original-client-ip>[^,]*)?,(?<original-server-ip>[^,]*)?,(?<custom-data>[^,]*)?,(?<transport-traffic-type>[^,]*)?,(?<log-id>[^,]*)?,(?<schema-version>[^,]*)?", value: message_field, only_named_captures: true);
set_fields(action);
end