Without ECS, the 'rt' field could be parsed fine and mapped into 'deviceReceiptTime' field. But after enabling ECS in Logstash configuration it throws me an error in log ingesting. Could somebody guide me through this as I am new to Logstash and Elastic Stack
Error log:
Jul 27 04:03:33 siem-cmerp logstash[95486]: parse_cef_format_sgring("2022-07-27T12:03:33+08:00", nil) #!=> Text '2022-07-27T12:03:33+08:00' could not be parsed at index 0
Jul 27 04:03:33 siem-cmerp logstash[95486]: [2022-07-27T04:03:33,236][ERROR][logstash.codecs.cef ][insight][123826a1a734cffe10ba61160d1569e3c5e2d3d6ff5fbbab4c8dc2459f2ac557] Failed to parse CEF timestamp value `2022-07-27T12:03:33+08:00` (Text '2022-07-27T12:03:33+08:00' could not be parsed at index 0)
Jul 27 04:03:33 siem-cmerp logstash[95486]: [2022-07-27T04:03:33,238][ERROR][logstash.codecs.cef ][insight][123826a1a734cffe10ba61160d1569e3c5e2d3d6ff5fbbab4c8dc2459f2ac557] Failed to decode CEF payload. Generating failure event with payload in message field. {:exception=>LogStash::Codecs::CEF::InvalidTimestamp, :message=>"Not a valid CEF timestamp: `2022-07-27T12:03:33+08:00`", :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-codec-cef-6.2.5-java/lib/logstash/codecs/cef.rb:556:in `normalize_timestamp'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-codec-cef-6.2.5-java/lib/logstash/codecs/cef.rb:273:in `block in handle'", "org/jruby/ext/set/RubySet.java:630:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-codec-cef-6.2.5-java/lib/logstash/codecs/cef.rb:271:in `handle'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-codec-cef-6.2.5-java/lib/logstash/codecs/cef.rb:200:in `decode'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-udp-3.5.0/lib/logstash/inputs/udp.rb:164:in `inputworker'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-udp-3.5.0/lib/logstash/inputs/udp.rb:76:in `block in run'"], :original_data=>"2022-07-27T12:03:33+08:00 InsightCef CEF:0|CMERP|INSIGHT|1|1075168|Common Name Without Domain Name|High|externalId=36521852 smac=50:3e:aa:e4:19:ae src=10.108.102.60 spt=45788 dst=139.59.84.212 dpt=443 proto=TCP deviceInboundInterface=ens33 app=tls cs2Label=payload cs2=FgMDAFkCAABVAwM4N5hdUCvLofKbysVEcf+k9bA155z5ac3m7UlUEcPjJiCe1erzxPbJgcslod4yNJETNVYvzvC7bcu4iK86QQnfM8AsAAAN/wEAAQAACwAEAwABAhYDAwGpCwABpQABogABnzCCAZswggEgoAMCAQICCAmSp7UGRJsyMAoGCCqGSM49BAMDMBQxEjAQBgNVBAMTCXN5bmN0aGluZzAeFw0xNjA5MTIwNzQ3MDhaFw00OTEyMzEyMzU5NTlaMBQxEjAQBgNVBAMTCXN5bmN0aGluZzB2MBAGByqGSM49AgEGBSuBBAAiA2IABBZdFkrxGGvCsOuPiZlD2mjEhpoKt9/nBW4nyZhWriBHO0oAmiXwZPW+3b7uAzwpL6Y5KL+uoac1b3OTgvYtcmQPDCyvxfdcHkf1onnkWBX2fmzyVETofFsLphGpl/3lHaM/MD0wDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMAoGCCqGSM49BAMDA2kAMGYCMQDEh1O8qY18xJ3ghSC5NhLWyzWoPE7AXUCDarXFB82wvwUOUdQ6e6CFFXfitKoSiQoCMQDXsQXAgGMXrogXWvQu3fOJZkBFtWAbVU1BjHDaDZtdqE9ruh8VBd8Cf99YuDRCP8UWAwMAswwAAK8DABdBBLwBs7xytgHz4BJgF7C5zO5X7QJcV6Cct2CpLLBYXk+PjlQ830g6pgVxOidwMGBmKI3wgyZcvAGqJQES4mh22NEGAwBmMGQCMG06bs6XkG3ZM9xJ2/TP0wsUiu0YFGOX/eruufdKdW1iLfj2PkiB+si6PSv2rDTisgIwK8mf+/92efdQbTvP0+qiWyZqVkUC0MzKtvuKdeVeTgUoDRxAkUOqTHTcWi8FFnwxFgMDAC4NAAAmAwECQAAeBgEGAgYDBQEFAgUDBAEEAgQDAwEDAgMDAgECAgIDAAAOAAAA cs3Label=threat_class cs3=Suspicious Network Interaction dvchost=Suri5a act=allowed deviceDirection=Inbound cs4Label=signature_techique_name cs4=Tls cs1Label=threat cs1=Common Name Without Domain Name cs5Label=sensor_id cs5=28 rt=2022-07-27T12:03:33+08:00"}
Jul 27 04:03:33 siem-cmerp logstash[95486]: [2022-07-27T04:03:33,352][ERROR][logstash.filters.ruby ][insight][01a1cc7bfbee2e1c78dabaa8545d03bddd39d5955d46e0fb6e751da45d382514] Ruby
exception occurred: undefined method `unpack1' for nil:NilClass {:class=>"NoMethodError", :backtrace=>["/usr/share/logstash/vendor/jruby/lib/ruby/stdlib/base64.rb:59:in `decode64'", "(ruby filter code):2:in `block in filter_method'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.8/lib/logstash/filters/ruby.rb:96:in `inline_script'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.8/lib/logstash/filters/ruby.rb:89:in `filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:159:in `do_filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:178:in `block in multi_filter'", "org/jruby/RubyArray.java:1821:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:175:in `multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:134:in `multi_filter'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:300:in `block in start_workers'"]}
Jul 27 04:03:33 siem-cmerp logstash[95486]: {
Jul 27 04:03:33 siem-cmerp logstash[95486]: "@version" => "1",
Jul 27 04:03:33 siem-cmerp logstash[95486]: "type" => "syslog",
Jul 27 04:03:33 siem-cmerp logstash[95486]: "host" => {
Jul 27 04:03:33 siem-cmerp logstash[95486]: "ip" => "10.108.201.243"
Jul 27 04:03:33 siem-cmerp logstash[95486]: },
Jul 27 04:03:33 siem-cmerp logstash[95486]: "tags" => [
Jul 27 04:03:33 siem-cmerp logstash[95486]: [0] "_cefparsefailure",
Jul 27 04:03:33 siem-cmerp logstash[95486]: [1] "insight",
Jul 27 04:03:33 siem-cmerp logstash[95486]: [2] "_rubyexception",
Jul 27 04:03:33 siem-cmerp logstash[95486]: [3] "_geoip_lookup_failure"
Jul 27 04:03:33 siem-cmerp logstash[95486]: ],
Jul 27 04:03:33 siem-cmerp logstash[95486]: "message" => "2022-07-27T12:03:33+08:00 InsightCef CEF:0|CMERP|INSIGHT|1|1075168|Common Name Without Domain Name|High|externalId=36521852 smac=50:3e:aa:e4:19:ae src=10.108.102.60 spt=45788 dst=139.59.84.212 dpt=443 proto=TCP deviceInboundInterface=ens33 app=tls cs2Label=payload cs2=FgMDAFkCAABVAwM4N5hdUCvLofKbysVEcf+k9bA155z5ac3m7UlUEcPjJiCe1erzxPbJgcslod4yNJETNVYvzvC7bcu4iK86QQnfM8AsAAAN/wEAAQAACwAEAwABAhYDAwGpCwABpQABogABnzCCAZswggEgoAMCAQICCAmSp7UGRJsyMAoGCCqGSM49BAMDMBQxEjAQBgNVBAMTCXN5bmN0aGluZzAeFw0xNjA5MTIwNzQ3MDhaFw00OTEyMzEyMzU5NTlaMBQxEjAQBgNVBAMTCXN5bmN0aGluZzB2MBAGByqGSM49AgEGBSuBBAAiA2IABBZdFkrxGGvCsOuPiZlD2mjEhpoKt9/nBW4nyZhWriBHO0oAmiXwZPW+3b7uAzwpL6Y5KL+uoac1b3OTgvYtcmQPDCyvxfdcHkf1onnkWBX2fmzyVETofFsLphGpl/3lHaM/MD0wDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMAoGCCqGSM49BAMDA2kAMGYCMQDEh1O8qY18xJ3ghSC5NhLWyzWoPE7AXUCDarXFB82wvwUOUdQ6e6CFFXfitKoSiQoCMQDXsQXAgGMXrogXWvQu3fOJZkBFtWAbVU1BjHDaDZtdqE9ruh8VBd8Cf99YuDRCP8UWAwMAswwAAK8DABdBBLwBs7xytgHz4BJgF7C5zO5X7QJcV6Cct2CpLLBYXk+PjlQ830g6pgVxOidwMGBmKI3wgyZcvAGqJQES4mh22NEGAwBmMGQCMG06bs6XkG3ZM9xJ2/TP0wsUiu0YFGOX/eruufdKdW1iLfj2PkiB+si6PSv2rDTisgIwK8mf+/92efdQbTvP0+qiWyZqVkUC0MzKtvuKdeVeTgUoDRxAkUOqTHTcWi8FFnwxFgMDAC4NAAAmAwECQAAeBgEGAgYDBQEFAgUDBAEEAgQDAwEDAgMDAgECAgIDAAAOAAAA cs3Label=threat_class cs3=Suspicious Network Interaction dvchost=Suri5a act=allowed deviceDirection=Inbound cs4Label=signature_techique_name cs4=Tls cs1Label=threat cs1=Common Name Without Domain Name cs5Label=sensor_id cs5=28 rt=2022-07-27T12:03:33+08:00",
Jul 27 04:03:33 siem-cmerp logstash[95486]: "@timestamp" => 2022-07-27T04:03:33.240160Z
Jul 27 04:03:33 siem-cmerp logstash[95486]: }
Logstash v8 configuration:
input {
udp {
port => 5524
ecs_compatibility => v8
codec => cef {}
type => syslog
tags => ["insight"]
}
}
filter {
date {
match => [ "rt", "ISO8601" ]
target => "@timestamp"
}
ruby {
code => 'event.set("[cef][device_custom_string_2][decoded]", Base64.decode64(event.get("[cef][device_custom_string_2][value]")))'
}
mutate {
gsub => [
"[event][severity]", "[\?#|-]", "",
"[cef][name]", "[\\\?#|-]", " ",
"[cef][device_custom_string_1][value]", "[\\\?#|-]", " ",
"[cef][device_custom_string_3][label]", "\_", " ",
"[cef][device_custom_string_4][value]", "[\_\=]", " ",
"[cef][device_custom_string_4][label]", "[\_]", " ",
"[cef][device_custom_string_5][label]", "[\_]", " "
]
}
geoip {
source => "[destination][ip]"
}
}
output {
elasticsearch {
hosts => ["*censored*:9200"]
index => "logs-insightcef-data-stream-test"
user => "*censored*"
password => "*censored*!"
action => "create"
}
stdout {
codec => rubydebug
}
}
Logstash pipeline configuration:
- pipeline.id: insight
path.config: "/etc/logstash/conf.d/insight-test.conf"
pipeline.ecs_compatibility: v8