-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombo.conf
More file actions
270 lines (232 loc) · 8.94 KB
/
Copy pathcombo.conf
File metadata and controls
270 lines (232 loc) · 8.94 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
input {
# udp {
# port => "514"
# type => "transparent"
# }
# ^^^ needs root?
udp {
port => "5140"
type => "transparent"
}
udp {
port => "5141"
type => "syslog-cisco-xr"
}
udp {
port => "5142"
type => "syslog-cisco-xe"
}
udp {
port => "5143"
type => "syslog-cisco-asa"
}
udp {
port => "5144"
type => "syslog-nokia-timos"
}
udp {
port => "5145"
type => "syslog-ne"
}
}
filter {
# NOTE: The frontend logstash servers set the type of incoming messages.
# Routers are sending the same message to all syslog servers for redundancy, this allows us to
## only store the message in elasticsearch once by generating a hash of the message and using that as
## the document_id.
fingerprint {
source => [ "message" ]
method => "SHA1"
key => "Some super secret passphrase for uniqueness."
concatenate_sources => true
}
if [type] == "syslog-cisco-xr" {
# FILTER - IOS XR format
#
# Configuration:
# clock timezone EET 2
# service timestamps log datetime localtime msec show-timezone year
# service timestamps debug datetime localtime msec show-timezone year
# logging format rfc5424/bsd
# logging 10.10.10.10 vrf default severity info port 5141
# logging source-interface Loopback0
# logging hostnameprefix __DISCOBEAR
# logging suppress duplicates
# Parse the log entry into sections. Cisco doesn't use a consistent log format, unfortunately.
grok {
# There are a couple of custom patterns associated with this filter.
# patterns_dir => [ "/usr/share/logstash/patterns" ]
match => [
# IOS-XR BSD Log Format
# "message", "<%{POSINT:pri}>%{DATA:log_date}__%{DATA:hostname} %{DATA:slot}:%{DATA:job_id}: %%{DATA:facility}-%{INT:lvl}-%{DATA:facility_mnemonic} : %{GREEDYDATA:message}",
# IOS-XR RFC5424 Logs
# v0.1 "message", "<%{POSINT:pri}>%{POSINT:version}%{SPACE}%{DATA:log_date}%{SPACE}__%{DATA:hostname} %{DATA:extjob}: %{DATA:slot}:%{DATA:job_id}: %%{DATA:facility}-%{INT:lvl}-%{DATA:facility_mnemonic} : %{GREEDYDATA:message}"
# v0.2 "message", "<%{POSINT:pri}>%{POSINT:version} %{YEAR:year} %{MONTH:month} %{MONTHDAY:monthday} %{TIME:time} %{DATA:tz} %{DATA:hostname} %{DATA:extjob}: %{DATA:slot}:%{DATA:job_id}: %%{DATA:facility}-%{INT:lvl}-%{DATA:facility_mnemonic} : %{GREEDYDATA:message}"
# Default XR with YEAR and TZ
"message", "<%{POSINT:pri}>%{POSINT:seq}: %{DATA:hostname} %{DATA:slot}:(%{YEAR:year})? %{MONTH:month}(%{SPACE})+%{MONTHDAY:monthday} %{TIME:time} (%{DATA:tz})?:%{DATA:job_id}: %%{DATA:facility}-%{INT:lvl}-%{DATA:facility_mnemonic} : %{GREEDYDATA:message}"
]
overwrite => [ "message" ]
add_tag => [ "iosxr" ]
remove_field => [ "pri", "@version" ]
} # grok
} # if type
if [type] == "syslog-cisco-xe" {
# FILTER - IOS XE
#
# Configuration:
# clock timezone EET 2 0
# service timestamps debug datetime msec localtime show-timezone year
# service timestamps log datetime msec localtime show-timezone year
# service sequence-numbers
# no logging count
# logging trap debugging
# logging origin-id hostname
# logging host 10.10.10.10 transport udp port 5142
grok {
# patterns_dir => [ "/usr/share/logstash/patterns" ]
match => [
# IOS-XE Log Format
"message", "<%{POSINT:pri}>(%{POSINT:seq2}: )?(%{DATA:hostname}: )?(%{NUMBER:seq}: )?(\.)?%{DATA:log_date}: %%{DATA:facility}-%{DATA:lvl}-%{DATA:facility_mnemonic}: %{GREEDYDATA:message}"
]
overwrite => [ "message" ]
add_tag => [ "cisco", "iosxe" ]
remove_field => [ "pri", "seq2", "@version" ]
} # grok
} # if type
if [type] == "syslog-cisco-asa" {
# Cisco ASA
#
# Configuration
grok {
match => [
"message", "<%{POSINT:pri}>%{MONTH:month} %{MONTHDAY:monthday} %{YEAR:year} %{TIME:time} %{DATA:hostname} : %%{DATA:facility}-%{POSINT:lvl}-%{DATA:facility_mnemonic}: %{GREEDYDATA:message}"
]
overwrite => [ "message" ]
add_tag => [ "asa" ]
remove_field => [ "pri", "@version" ]
} # grok
} # if type
if [type] == "syslog-ne" {
# FILTER - NE log format
#
# Configuration:
# info-center source default channel 0 log state off trap state off
# info-center source default channel 4 log level debugging
# info-center loghost 10.10.10.10 source-ip 1.1.1.1 port 5145 local-time
# info-center timestamp log format-date precision-time millisecond
# info-center timestamp trap format-date precision-time millisecond
grok {
# patterns_dir => [ "/usr/share/logstash/patterns" ]
match => [
# NE Logs
"message", "<%{POSINT:pri}>%{TIMESTAMP_ISO8601:log_date}%{SPACE}%{DATA:hostname}%{SPACE}%%%{DATA:facility}/%{POSINT:lvl}/%{DATA:facility_mnemonic}:%{DATA:cid};%{GREEDYDATA:message}"
]
overwrite => [ "message" ]
add_tag => [ "ne", "ISO8601" ]
remove_field => [ "pri", "@version" ]
} # grok
} # if type
if [type] == "syslog-nokia-timos" {
# FILTER - Nokia TiMOS log format
#
# Configuration:
# /configure log syslog 1 log-prefix 7210SASMXPLAB1
# /configure log syslog 1 description LOGSTASH
# /configure log syslog 1 address 10.10.10.10
# /configure log syslog 1 port 5144
# /configure log log-id 85 time-format local
# /configure log log-id 90 time-format local
# /configure log log-id 95 time-format local
# /configure log log-id 97 time-format local
grok {
# patterns_dir => [ "/usr/share/logstash/patterns" ]
match => [
# Nokia Logs
"message", "<%{POSINT:pri}>%{CISCOTIMESTAMP:log_date} %{DATA:hostip} %{DATA:hostname}: %{POSINT:seq} %{DATA:base} %{DATA:facility}-%{DATA:lvl}-%{DATA:facility_mnemonic}-%{GREEDYDATA:message}"
]
overwrite => [ "message" ]
add_tag => [ "timos", "nokia", "ISO8601" ]
remove_field => [ "pri", "@version" ]
} # grok
} # if type
# If we made it here, the grok was sucessful
if "cisco" in [tags] {
date {
match => [
"log_date",
# IOS
"MMM dd HH:mm:ss.SSS ZZZ",
"MMM dd HH:mm:ss ZZZ",
"MMM dd HH:mm:ss.SSS",
"MMM dd YYYY HH:mm:ss.SSS ZZZ",
"MMM dd YYYY HH:mm:ss ZZZ",
"MMM dd YYYY HH:mm:ss.SSS",
"MMM d YYYY HH:mm:ss.SSS ZZZ",
"MMM d YYYY HH:mm:ss",
"MMM dd YYYY HH:mm:ss",
# Nexus
"YYYY MMM dd HH:mm:ss.SSS ZZZ",
"YYYY MMM dd HH:mm:ss ZZZ",
"YYYY MMM dd HH:mm:ss.SSS",
# Hail Mary
"ISO8601"
]
} # date
} # if tags
if "ISO8601" in [tags] {
date {
match => [
"log_date",
"ISO8601"
]
} # date
} # if tags
if "iosxr" in [tags] {
mutate {
add_field => {
"log_date" => "%{monthday}/%{month}/%{year}:%{time}"
}
}
date {
locale => "en"
timezone => "EET"
match => ["log_date", "dd/MMM/yyyy:HH:mm:ss.SSS"]
target => "@timestamp"
remove_field => [ "month", "monthday", "year", "time"] #log_date
}
} # if tags
if "asa" in [tags] {
mutate {
add_field => {
"log_date" => "%{monthday}/%{month}/%{year}:%{time}"
}
}
date {
locale => "en"
# TODO: Flexible timezone
timezone => "EET"
match => ["log_date", "dd/MMM/yyyy:HH:mm:ss"]
target => "@timestamp"
remove_field => [ "month", "monthday", "year", "time"] #log_date
}
} # if tags
# Add the log level name instead of just a number.
mutate {
gsub => [
"lvl", "0", "0 emerg",
"lvl", "1", "1 alert",
"lvl", "2", "2 critical",
"lvl", "3", "3 error",
"lvl", "4", "4 warning",
"lvl", "5", "5 notice",
"lvl", "6", "6 info",
"lvl", "7", "7 debug"
]
} # mutate
} # filter
output {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "syslogindex"
}
}