Skip to content

Commit 02a6ac3

Browse files
authored
Update suricata.conf
1 parent 8e71e5e commit 02a6ac3

1 file changed

Lines changed: 52 additions & 16 deletions

File tree

filters/suricata/suricata.conf

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
filter {
22

3-
# Suricata filter version 1.0.0
3+
# Suricata filter version 1.0.4
44
# Based on https://suricata.readthedocs.io/en/latest/output/eve/eve-json-format.html (latest 8.0.0) (august 2025)
55
# and real events log provided
66
# Support json format
@@ -24,11 +24,27 @@ filter {
2424
}
2525

2626
if ![dataType] {
27-
if [path] and [path] == "/var/log/suricata/eve.json" {
28-
if [message] {
29-
json { source => "message" }
27+
# Parse Suricata logs from syslog
28+
if [message] =~ /suricata\[\d+\]:.*event_type/ {
29+
grok {
30+
match => {
31+
"message" => "<%{POSINT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_timestamp} %{HOSTNAME:syslog_host} %{PROG:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:suricata_json}"
3032
}
31-
if [event_type] and ([event_type] == "anomaly" or [event_type] == "tls" or [event_type] == "flow"
33+
tag_on_failure => ["_grokparsefailure_suricata"]
34+
}
35+
36+
if [suricata_json] {
37+
json {
38+
source => "suricata_json"
39+
}
40+
mutate {
41+
remove_field => ["suricata_json", "syslog_pri", "syslog_timestamp", "syslog_program", "syslog_pid"]
42+
}
43+
}
44+
45+
46+
# Process all Suricata event types (from both syslog and file)
47+
if [event_type] and ([event_type] == "anomaly" or [event_type] == "tls" or [event_type] == "flow"
3248
or [event_type] == "alert" or [event_type] == "dns" or [event_type] == "ssh"
3349
or [event_type] == "http" or [event_type] == "ftp" or [event_type] == "ftp_data"
3450
or [event_type] == "tftp" or [event_type] == "smb" or [event_type] == "initial_request"
@@ -49,20 +65,36 @@ filter {
4965
rename => ["src_port", "[logx][suricata][src_port]"]
5066
rename => ["tx_id", "[logx][suricata][tx_id]"]
5167
}
68+
}
69+
70+
# Set dataSource from syslog_host or host
71+
if (![dataSource]){
72+
if [syslog_host] {
73+
mutate {
74+
add_field => { "dataSource" => "%{syslog_host}" }
5275
}
53-
if (![dataSource]){
54-
mutate {
55-
add_field => { "dataSource" => "%{host}" }
56-
}
57-
}
58-
76+
} else if [host] {
5977
mutate {
60-
add_field => {
61-
"dataType" => "suricata"
62-
}
63-
remove_field => [ "timestamp", "type", "path"]
64-
rename => ["event_type", "[logx][suricata][event_type]"]
78+
add_field => { "dataSource" => "%{host}" }
79+
}
80+
}
81+
}
82+
83+
# Clean up syslog_host field after using it
84+
if [syslog_host] {
85+
mutate {
86+
remove_field => ["syslog_host"]
87+
}
88+
}
89+
90+
# Add dataType and clean up fields
91+
mutate {
92+
add_field => {
93+
"dataType" => "suricata"
6594
}
95+
remove_field => [ "timestamp", "type", "path"]
96+
rename => ["event_type", "[logx][suricata][event_type]"]
97+
}
6698
if [tls] {
6799
mutate {
68100
rename => ["tls", "[logx][suricata][tls]"]
@@ -374,5 +406,9 @@ filter {
374406
}
375407
}
376408
}
409+
# Remove fields that are not needed
410+
mutate {
411+
remove_field => ["original_log_message", "suricata_json"]
412+
}
377413
}
378414
}

0 commit comments

Comments
 (0)