13. PARSING LOGS
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
14. PARSING LOGS
^(?#regex designed to parse VyOS kernel log)(?#some global parsing,
like timestamp, fitlter, interfaces, and so on)(?<time>[^ ]* [^ ]* [
^ ]*) (?<host>[^ ]*) (?<vyos_sylog_facility>[^: ]*)?: [(?<vyos_fw_f
ilter_name>[^[]*)] ?IN=( |(?<vyos_in_interface>[^ ]*) )OUT=( |(?<v
yos_out_interface>[^ ]*) )(MAC=( |(?<vyos_mac_addres>[^ ]*) ))?SRC=(
|(?<vyos_source_ip_address>[^ ]*) )DST=( |(?<vyos_dstination_ip_add
ress>[^ ]*) )LEN=( |(?<vyos_len>[^ ]*) )TOS=( |(?<vyos_tos>[^ ]*) )P
REC=( |(?<vyos_prec>[^ ]*) )TTL=( |(?<vyos_ttl>[^ ]*) )ID=( |(?<vyps
_packet_id>[^ ]*) )(?<vyos_packet_flags>[^ |(PROTO)]*)? ?PROTO=( |(?
<vyps_ip_protocol>[^ ]*))(?#here comes the fun part, different parse
r for different interesting packet types, regex if and positive look
behind matching each type of interesting )(?:(?<=(TCP))((?#tcp speci
fic matchers) ?SPT=( |(?<vyos_source_port>[^ ]*) )DPT=( |(?<vyos_des
tination_port>[^ ]*) )WINDOW=( |(?<vyos_tcp_window>[^ ]*) )RES=( |(?
<vyos_res>[^ ]*) )(?<vyps_tcp_state>[^(URGP)]* ).*)|(?:(?<=(UDP))((?
#udp specific matchers) ?SPT=( |(?<vyos_source_port>[^ ]*) )DPT=( |(
?<vyos_destination_port>[^ ]*) ).*)|(?:(?<=(ICMP))((?#icmp specific
matchers) TYPE=( |(?<vyos_icmp_type>[^ ]*) )CODE=( |(?<vyos_icmp_cod
e>[^ ] )).*)|(.*))))$
15. CUSTOM SOLUTION?
Implement custom data collection within the application
Populate data with Servlet filters or Spring AOP
Index data in Elasticsearch