# Author: Justin Henderson
#         SANS Instructor and author of SANS SEC555: SIEM and Tactical Analytics
# Updated by: Doug Burks
# Last Update: 2/7/2018
#
# This conf file is based on accepting logs for notice.log from Bro systems
filter {
  if [type] == "bro_notice" {
        # If message looks like json, try to parse it as such. Otherwise, fall back to csv or grok.
        if [message] =~ /^{.*}$/ {
                json {
                        source => "message"
                }

                mutate {
                        rename => { "ts" => "timestamp" }
                        #uid
                        rename => { "id.orig_h" => "source_ip" }
                        rename => { "id.orig_p" => "source_port" }
                        rename => { "id.resp_h" => "destination_ip" }
                        rename => { "id.resp_p" => "destination_port" }
			#fuid
			rename => { "mime" => "file_mime_type" }
			rename => { "desc" => "file_description" }
			rename => { "proto" => "protocol" }
			rename => { "note" => "note" }
			rename => { "msg" => "msg" }
			rename => { "sub" => "sub_msg" }
			rename => { "src" => "source_ip" }
			rename => { "dst" => "destination_ip" }
			#p
			#n
			rename => { "peer_descr" => "peer_description" }
			rename => { "actions" => "action" }
			#suppress_for
			#destination_country_code
			#destination_region
			#destination_city
			#destination_latitude
			#destination_longitude
		}
	} else {
	    mutate {
	      gsub => [ "message", "[\"']", "" ]
	    }
	    csv {
	      columns => ["timestamp","uid","source_ip","source_port","destination_ip","destination_port","fuid","file_mime_type","file_description","protocol","note","msg","sub_msg","source_ip","destination_ip","p","n","peer_description","action","suppress_for","destination_country_code","destination_region","destination_city","destination_latitude","destination_longitude"]
	      separator => "	"
	    }
	}

	mutate {
		#add_tag => [ "conf_file_1109"]
	}
  }
}
