I’m sending logs from Fortinet FortiAnalyzer to Graylog in CEF formatting. I’m having issues with forwarded logs from a certain type of device. The first issue is that the field values have " .ad" added to the end of them. The second issue is the timestamp is coming in as UTC but being seen as EDT/EST so logs are ahead 4 hours.
I setup a raw TCP input to send the CEF TCP messages to, they look like this:
rule “type fortinet-faz-utc-ems-chromebook”
// we want to convert utc to edt timestamp
when
has_field(“os”) && to_string($message.os) == “cros ad.” &&
grok(pattern: “%{MONTH} +%{MONTHDAY}(?: %{YEAR})? %{TIME}”, value:to_string($message.start)).matches == true
then
let time = parse_date(value:to_string($message.start), pattern:“yyyy MMM dd HH:mm:ss.SSS”, timezone:“UTC”);
set_field(“timestamp”,time);
Remove certain number of characters from the end of a string
Set timestamp without correct timezone to UTC so it displays correctly in local est/edt
Pipeline stage 0
rule “type fortinet-faz-utc-ems-chromebook-os”
// we want to remove " .ad" from the os field
when
has_field(“os”) && to_string($message.os) == “cros ad.”
then
let var_os1 = to_string($message.os);
remove_field(“os”);
set_field(“os”, substring(var_os1, 0, -4));
end
rule “type fortinet-faz-utc-ems-chromebook-start”
// we want to remove " .ad" from the start field
when
has_field(“start”) &&
grok(pattern: “%{MONTH} +%{MONTHDAY}(?: %{YEAR})? %{TIME} ad.”, value:to_string($message.start)).matches == true
then
let var_start1 = to_string($message.start);
remove_field(“start”);
set_field(“start”, substring(var_start1, 0, -4));
end
Pipeline Stage 1
rule “type fortinet-faz-utc-ems-chromebook-timestamp-2n”
// we want to convert timestamp without timezone into utc two number day
when
has_field(“start”) &&
grok(pattern: “%{MONTH} %{MONTHDAY} %{YEAR} %{TIME}”, value:to_string($message.start)).matches == true
then
let time = parse_date(value:to_string($message.start), pattern:“MMM dd yyyy HH:mm:ss”, timezone:“UTC”);
set_field(“timestamp”,time);
end
rule “type fortinet-faz-utc-ems-chromebook-timestamp-1n”
// we want to convert timestamp without timezone into utc one number day
when
has_field(“start”) &&
grok(pattern: “%{MONTH} %{MONTHDAY} %{YEAR} %{TIME}”, value:to_string($message.start)).matches == true
then
let time = parse_date(value:to_string($message.start), pattern:“MMM d yyyy HH:mm:ss”, timezone:“UTC”);
set_field(“timestamp”,time);
end