-
Notifications
You must be signed in to change notification settings - Fork 8
/
opnsense.logstash.conf
135 lines (132 loc) · 3.8 KB
/
opnsense.logstash.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
input {
syslog {
# port => 5140
type => "syslog"
}
}
filter {
if [type] == "syslog" {
mutate { strip => ["message"] }
if [program] == "devd" {
if "!system=CAM" in [message] {
grok {
match => {"message" => "Processing event %{QUOTEDSTRING:data}"}
}
kv {source => "data"}
mutate { remove_field => 'data' }
}
drop { }
}
if [program] == "filterlog" {
opnsensefilter { field_name => "message" }
geoip { source => "source" }
if [geoip.ip] {
geoip {
source => "source"
target => "destination"
}
}
if ![geoip.ip] {
geoip { source => "destination" }
}
}
if [program] == "suricata" {
geoip { source => "src_ip" }
if [geoip.ip] {
geoip {
source => "src_ip"
target => "dest_ip"
}
}
if ![geoip.ip] {
geoip { source => "dest_ip" }
}
}
if [program] == "opnsense" or [program] == 'opnsense-devel' {
if "for" in [message] and "from" in [message] {
mutate { add_field => {'os_type' => 'auth'} }
if "from:" in [message] {
grok {
match => {
"message" => "%{DATA:scriptname}: %{DATA:login_status} for user '%{USERNAME:username}' from: %{DATA:ip}"
}
}
}
else {
grok {
match => {
"message" => "%{DATA:scriptname}: %{DATA:login_status} for '%{USERNAME:username}' from %{DATA:ip}"
}
}
}
}
}
if [program] == "configd.py" {
if "message" in ["message"] {
grok {
match => {
"message" => "message %{UUID:uuid} \[%{DATA:action_name}\] returned %{WORD:status_word}.*"
}
}
}
if [message] =~ "^\[.+?\]" {
grok {
match => {"message" => "\[%{UUID:uuid}\] %{GREEDYDATA:configd_message}"}
}
}
if [message] =~ "^\S+* generated \S+$" {
grok {
match => {"message" => "^%{NOTSPACE:component_name} generated %{NOTSPACE:file_name}$"}
}
}
#mutate { remove_field => 'message' }
}
if [program] == "/usr/sbin/cron" {
grok {
match => {"message" => "\(%{USER:user}\) CMD %{GREEDYDATA:cron_message}"}
}
mutate { remove_field => 'message' }
}
if [program] in ["ospfd", "ospf6d"] {
if ":" in [message] {
grok {
match => {"message" => "%{DATA:component}: %{GREEDYDATA:sub_message}"}
}
}
if ":" in [sub_message] and "# Areas" not in [sub_message] {
grok {
match => {"sub_message" => "%{DATA:subcomponent}: %{GREEDYDATA:msg}"}
}
mutate { remove_field => "sub_message" }
mutate { rename => {"msg" => "sub_message"} }
}
if [message] =~ /^\S+\(\S+\).*/ {
grok {
match => {"message" => "%{NOTSPACE:component}\(%{NOTSPACE:function_name}\) %{GREEDYDATA:sub_message}"}
}
}
if [component] == "SPF" {
grok {
match => {"sub_message" => "Scheduled in %{NUMBER:scheduled} msec"}
}
}
if [component] == "SPF processing" {
grok {
match => {"sub_message" => "# Areas: %{NUMBER:number_areas}, SPF runtime: %{NUMBER:runtime_sec} sec %{NUMBER:runtime_usec} usec, Reason: %{GREEDYDATA:reason}"}
}
}
}
#"SPF processing: # Areas: 1, SPF runtime: 0 sec 0 usec, Reason: R+, R-"
#"OSPF6d (Quagga-1.2.1 ospf6d-0.9.7r) starts: vty@2606"
if [program] == "zebra" {
#"client 18 says hello and bids fair to announce only ospf6 routes"
}
}
}
output {
#stdout { codec => rubydebug }
elasticsearch {
hosts => "http://localhost:9200"
index => "logstash-opnsense-syslog-%{+YYYY.MM.dd}"
}
}