-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolace_logstash.conf
330 lines (300 loc) · 18.7 KB
/
solace_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
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#############################################################################################################
# Logstash/grok conf file for receiving Solace event broker logs (command, event, system)
#
# These
# https://docs.solace.com/System-and-Software-Maintenance/Monitoring-Events-Using-Syslog.htm
#
# Input section, where we define how these are received via Syslog
# Can specify multiple ports to listen to, which can delineate different environments and therefore apply different rules
input {
syslog {
port => "51420"
add_field => { "env" => "dev" }
# NOTE: Solace brokers only use crit, err, warn, notice, info ... not the others, but they're part of RFC 3164, section 4.1.1: https://datatracker.ietf.org/doc/html/rfc3164#section-4.1.1
severity_labels => [ "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug" ]
}
syslog {
port => "51421"
add_field => { "env" => "test" }
severity_labels => [ "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug" ]
}
syslog {
port => "51422"
add_field => { "env" => "prod" }
severity_labels => [ "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug" ]
}
}
# Filter section, where I add/modify stuff for each of the different logs
filter {
mutate {
# remove the ending newline char
strip => [ "message" ]
# set to true for raw text logging to /var/log/solace.logstash/
add_field => { "[@metadata][fileoutput]" => "true" }
# set to true for insertion into elastic
add_field => { "[@metadata][elasticoutput]" => "false" }
# set to true for debug dump of parsed data to /tmp/solace.<blah>.log
add_field => { "[@metadata][debug]" => "true" }
}
ruby {
# this is to get the local time and date with TZ offset, stored in var 'localdate'
code => "event.set('localdate', event.get('@timestamp').time.localtime.strftime('%Y-%m-%dT%H:%M:%S.%3N%z'))"
}
if [facility_label] == "local1" { # command log
grok {
# for command log, don't need severity, priority, or facility
remove_field => [ "severity", "severity_label", "priority", "facility" ]
# ending timestamps aren't always there, and sometimes the status is multiword
# 2018-01-16T06:04:05+08: sg-sol-3501-vmr alee[8745]: CLI/1 192.168.42.243 alee 06:04:04 06:04:05 ok (configure/syslog)# facility event
# ok, so command log message will look something like:
# CLI/1 192.168.42.243 alee 06:04:01 pre-execution (configure)# syslog external
# CLI/1 192.168.42.243 alee 06:04:01 06:04:01 changed mode (configure)# syslog external
# CLI/1 192.168.42.243 alee 06:04:04 06:04:05 ok (configure/syslog)# facility event
# CLI/1 192.168.42.243 alee 06:04:06 06:04:06 ok (configure/syslog)# exit
# or
# SHELL CLI/1 alee --- --- --- (/usr/sw/support) ls /usr/sw/jail/logs
break_on_match => "false"
match => { "message" => "^%{NOTSPACE:method} {2,}%{NOTSPACE:source} {2,}%{NOTSPACE:userid} {2,}%{DATA:execution_details} {8,}%{GREEDYDATA:cmd}" }
match => { "execution_details" => "^%{NOTSPACE:start}(?: {2,}%{NOTSPACE:end})? {2,}%{GREEDYDATA:result}" }
remove_field => [ "execution_details" ]
}
# in newer SolOS, the 'show' commands have a "> " at the start, unlike old SEMP. For CLI, there's always the "path"
if ([method] =~ /^SEMP/ and [cmd] =~ /^(?:> )?show/) or ([method] =~ /^CLI/ and [cmd] =~ /^\(?.*?[#>] show/) {
mutate {
# this is a show command, not a config command
add_field => { "[@metadata][command]" => "show" }
}
} else {
mutate {
add_field => { "[@metadata][command]" => "config" }
# this next line is only used by the Solace output plugin, mostly for testing
add_field => { "solace-topic" => "log/cmd/%{logsource}/cli/" }
}
}
#################################################
# EVENT LOG
##################################################
} else if [facility_label] == "local3" {
grok {
add_tag => [ "broker %{logsource}" ]
match => { "message" => "^%{WORD:scope}: %{USERNAME:event}: %{GREEDYDATA:message}" }
overwrite => [ "message" ]
add_tag => [ "event %{event}" ]
}
# check to see if the event log tag is set
if [program] != "event" {
# means that event log tag is set for this broker or VPN
grok {
# remove the last 4 chars, as they are the severity (e.g. 'aaronvpnNOTI' --> 'aaronvpn'), and save to new var 'log_tag'
match => { "program" => "^%{DATA:log_tag}.{4}$" }
}
}
mutate {
# don't need priority or facility
remove_field => [ "priority", "facility" ]
}
if [scope] == "SYSTEM" {
grok {
match => { "message" => "^- - %{GREEDYDATA:message}" } # chop those stupid - - marks ("VPN" and "client name")
overwrite => [ "message" ]
# this next line is only used by the Solace output plugin, mostly for testing
add_field => { "solace_topic" => "log/%{severity_label}/system/%{logsource}/%{event}" }
}
if ([event] == "SYSTEM_AUTHENTICATION_SESSION_OPENED"
or [event] == "SYSTEM_AUTHENTICATION_SESSION_CLOSED"
or [event] == "SYSTEM_CLIENT_CONNECT_AUTH_FAIL"
or [event] == "SYSTEM_SSL_CONNECTION_REJECTED") {
mutate { add_field => { "[@metadata][event]" => "auth" } }
} else { # it's not an authentication/connection issue, let's check if we might want to alert on this
mutate { add_field => { "[@metadata][event]" => "system" } }
if [severity] <= 5 or
"CLEAR" in [event] or
"UP" in [event] or
"ENABLE" in [event] {
mutate { add_field => { "[@metadata][alert]" => "true" } }
}
}
} else {
if [scope] == "VPN" {
grok {
add_field => { "[@metadata][event]" => "vpn" }
# don't use a backreference anymore, because some VPN events (e.g. queue delete, SolCache, etc.) don't have the VPN name repeated
#match => { "message" => "^%{NOTSPACE:vpn} - Message VPN \([0-9]+\) %{GREEDYDATA:message}" }
match => { "message" => "^%{NOTSPACE:vpn} - Message VPN \(%{BASE10NUM:vpnId:int}\) %{GREEDYDATA:message}" }
overwrite => [ "message" ]
add_tag => [ "vpn %{vpn}" ]
# this next line is only used by the Solace output plugin, mostly for testing
add_field => { "solace-topic" => "log/%{severity_label}/vpn/%{logsource}/%{event}/%{vpn}" }
}
# Special parsing rules
if [event] == "VPN_VPN_STATE_CHANGE" {
#grok { match => { "message" => "^Message VPN \([0-9]+\) %{DATA:qtype} %{DATA:qname} deleted, final statistics \- spool\(%{BASE10NUM:lastMsgIdSpooled:int}, %{BASE10NUM:lowMsgIdAcked:int}, %{BASE10NUM:highMsgIdAcked:int}, %{BASE10NUM:msgRedelivered:int}, %{BASE10NUM:spoolUsageExceeded:int}, %{BASE10NUM:bytesSpooled:int}, %{BASE10NUM:msgsSpooled:int}\) bind\(%{BASE10NUM:bindRequests:int}, %{BASE10NUM:bindRespOk:int}, %{BASE10NUM:bindRespAlreadyBound:int}, %{BASE10NUM:bindRespExceededClients:int}, %{BASE10NUM:bindRespOther:int}\)$" } }
grok { match => { "message" => "^%{DATA:name} State Changed to: %{DATA:operationalState}$" } }
} else if [event] == "VPN_AD_QENDPT_DELETE" {
grok { match => { "message" => "^%{DATA:qtype} %{DATA:qname} deleted, final statistics \- spool\(%{BASE10NUM:lastMsgIdSpooled:int}, %{BASE10NUM:lowMsgIdAcked:int}, %{BASE10NUM:highMsgIdAcked:int}, %{BASE10NUM:msgRedelivered:int}, %{BASE10NUM:spoolUsageExceeded:int}, %{BASE10NUM:bytesSpooled:int}, %{BASE10NUM:msgsSpooled:int}\) bind\(%{BASE10NUM:bindRequests:int}, %{BASE10NUM:bindRespOk:int}, %{BASE10NUM:bindRespAlreadyBound:int}, %{BASE10NUM:bindRespExceededClients:int}, %{BASE10NUM:bindRespOther:int}\)$" } }
}
} else if [scope] == "CLIENT" {
grok {
add_field => { "[@metadata][event]" => "client" }
match => { "message" => "^%{NOTSPACE:vpn} (?<client>%{DATA}) Client \(%{BASE10NUM:clientId:int}\) \k<client> username %{NOTSPACE:username} %{GREEDYDATA:message2}" }
#match => { "message" => "^%{NOTSPACE:vpn} %{NOTSPACE:client}ername} %{GREEDYDATA:message}" }
#overwrite => [ "message2" ]
add_tag => [ "vpn %{vpn}" ]
add_tag => [ "client %{client}" ]
add_tag => [ "username %{username}" ]
# this next line is only used by the Solace output plugin, mostly for testing
add_field => { "solace-topic" => "log/%{severity_label}/client/%{logsource}/%{event}/%{vpn}/%{client}" }
}
# Special parsing rules
if [event] == "CLIENT_CLIENT_CONNECT" {
grok {
match => { "message2" => "^OriginalClientUsername\(%{DATA:originalUsername}\) WebSessionId \(%{DATA:sessionId}\) connected to %{DATA:applianceIP}:%{BASE10NUM:appliancePort:int} from %{DATA:clientIP}:%{BASE10NUM:clientPort:int} version\(%{DATA:sdkVersion}\) platform\(%{DATA:platform}\) SslVersion\(%{DATA:sslVersion}\) SslCipher\(%{DATA:sslCipherDescription}\) APIuser\(%{DATA:userIdString}\) authScheme\(%{DATA:authSchemeString}\) authorizationGroup\(%{DATA:authorizationGroup}\) clientProfile\(%{DATA:clientProfile}\) ACLProfile\(%{DATA:aclProfile}\) SSLDowngradedToPlainText\(%{DATA:sslDowngradedToPlainText}\) SslRevocation\(%{DATA:sslRevocation}\)$" } }
} else if [event] == "CLIENT_CLIENT_DISCONNECT" {
grok {
match => { "message2" => "^WebSessionId \(%{DATA:sessionId}\) reason\(%{DATA:disconnectReason}\) final statistics \- dp\(%{BASE10NUM:controlMsgsReceived:int}, %{BASE10NUM:controlMsgsDelivered:int}, %{BASE10NUM:topicMsgsReceived:int}, %{BASE10NUM:topicMsgsDelivered:int}, %{BASE10NUM:totalMsgsReceived:int}, %{BASE10NUM:totalMsgsDelivered:int}, %{BASE10NUM:controlBytesReceived:int}, %{BASE10NUM:controlBytesDelivered:int}, %{BASE10NUM:topicBytesReceived:int}, %{BASE10NUM:topicBytesDelivered:int}, %{BASE10NUM:totalBytesReceived:int}, %{BASE10NUM:totalBytesDelivered:int}, %{BASE10NUM:curMsgRateIngress:int}, %{BASE10NUM:curMsgRateEgress:int}, %{BASE10NUM:avgMsgRateIngress:int}, %{BASE10NUM:avgMsgRateEgress:int}, %{BASE10NUM:deniedDuplicateClients:int}, %{BASE10NUM:discardsNoSubscriptionMatch:int}, %{BASE10NUM:discardsTopicParseError:int}, %{BASE10NUM:discardsParseError:int}, %{BASE10NUM:discardsMsgTooBig:int}, %{BASE10NUM:discardsTransmitCongestion:int}\) conn\(%{BASE10NUM:recvQBytes:int}, %{BASE10NUM:sendQBytes:int}, %{DATA:clientAddr}:%{BASE10NUM:clientPort:int}, %{DATA:state}, %{BASE10NUM:outOfOrder:int}, %{BASE10NUM:fastRetransmit:int}, %{BASE10NUM:timedRetransmit:int}\) zip\(%{BASE10NUM:compressedBytesReceived:int}, %{BASE10NUM:compressedBytesDelivered:int}, %{BASE10NUM:uncompressedBytesReceived:int}, %{BASE10NUM:uncompressedBytesDelivered:int}, %{DATA:compressionRatioIngress}, %{DATA:compressionRatioEgress}, %{BASE10NUM:curCompressedByteRateIngress:int}, %{BASE10NUM:curCompressedByteRateEgress:int}, %{BASE10NUM:curUncompressedByteRateIngress:int}, %{BASE10NUM:curUncompressedByteRateEgress:int}, %{BASE10NUM:avgCompressedByteRateIngress:int}, %{BASE10NUM:avgCompressedByteRateEgress:int}, %{BASE10NUM:avgUncompressedByteRateIngress:int}, %{BASE10NUM:avgUncompressedByteRateEgress:int}\) web\(%{BASE10NUM:webMsgsReceived:int}, %{BASE10NUM:webMsgsDelivered:int}, %{BASE10NUM:webBytesReceived:int}, %{BASE10NUM:webBytesDelivered:int}, %{BASE10NUM:webOutOfOrder:int}, %{BASE10NUM:webFastRetransmit:int}, %{BASE10NUM:webTimedRetransmit:int}\), SslVersion\(%{DATA:sslVersion}\), SslCipher\(%{DATA:sslCipherDescription}\)$" } }
} else if [event] == "CLIENT_CLIENT_CLOSE_FLOW" {
#grok { match => { "message2" => "^Pub flow session flow name %{DATA:flowName} \(%{BASE10NUM:flowId:int}\), publisher id %{BASE10NUM:pubId:int}, last message id %{BASE10NUM:lastMsgIdSent:int}, window size %{BASE10NUM:windowSize:int}, final statistics \- flow\(%{BASE10NUM:spoolingNotReady:int}, %{BASE10NUM:outOfOrderMessages:int}, %{BASE10NUM:duplicateMessages:int}, %{BASE10NUM:noEligibleDestinations:int}, %{BASE10NUM:spoolOverQuota:int}, %{BASE10NUM:qendptOverQuota:int}, %{BASE10NUM:maxMsgUsageExceeded:int}, %{BASE10NUM:maxMsgSizeExceeded:int}, %{BASE10NUM:remoteRouterNoSpooling:int}, %{BASE10NUM:spoolToADBFail:int}, %{BASE10NUM:spoolToDiskFail:int}, %{BASE10NUM:erroredMessage:int}, %{BASE10NUM:queueNotFound:int}, %{BASE10NUM:spoolShutdown:int}, %{BASE10NUM:denyGuaranteed:int}, %{BASE10NUM:noLocalDelivery:int}, %{BASE10NUM:smfTtlExceeded:int}, %{BASE10NUM:publishAclDenied:int}, %{BASE10NUM:destinationGroupError:int}, %{BASE10NUM:forwardModeMismatch:int}, %{BASE10NUM:lowPriorityMsgCongestionDiscard:int}, %{BASE10NUM:spoolFileLimitExceeded:int}, %{BASE10NUM:replicationIsStandby:int}, %{BASE10NUM:syncReplicationIneligible:int}, %{BASE10NUM:msgsReceived:int}\)$" } }
} else if [event] == "CLIENT_CLIENT_UNBIND" {
grok { match => { "message2" => "^Unbind to %{DATA:validInvalid} \(%{BASE10NUM:flowId:int}\), ForwardingMode\(%{DATA:forwardingMode}\), final statistics \- flow\(%{BASE10NUM:windowSize:int}, %{BASE10NUM:usedWindow:int}, %{BASE10NUM:unackedMessages:int}, %{BASE10NUM:lowMsgIdAckPending:int}, %{BASE10NUM:highMsgIdAckPending:int}, %{BASE10NUM:windowClosed:int}, %{BASE10NUM:msgRedelivered:int}, %{BASE10NUM:msgDeliveredStoreAndForward:int}, %{BASE10NUM:msgDeliveredCutThrough:int}\), isActive\(%{DATA:isActive}\), Reason\(%{DATA:reason}\)$" } }
}
} else {
# didn't match SYSTEM, VPN, or CLIENT??
mutate {
add_tag => [ "NOTHING event" ]
}
}
# this is where we'll have the alertable bits
if [severity] <= 4 or
"CLEAR" in [event] or
"UP" in [event] or
"DOWN" in [event] or
"ENABLE" in [event] or
"VPN_SOLCACHE" in [event] or
"VPN_BRIDGING_LINK" in [event] and
!([event] == "CLIENT_CLIENT_BIND_FAILED" or # warn, maybe we should emit if in prod?
[event] == "VPN_VPN_STATE_CHANGE" or # also warn
"VPN_SERVICE" in [event]) {
mutate { add_field => { "[@metadata][alert]" => "true" } }
}
}
#mutate { remove_field => [ "message" ] }
#################################################
# SYSTEM LOG
##################################################
} else if [facility_label] == "local4" { # who cares about system log? just use event.log
mutate { add_field => { "[@metadata][system]" => "system.log" } }
} else {
# mutate { add_field => { "status" => "Did not match local1, local3, or local4!" } }
}
}
output {
if "_grokparsefailure" in [tags] {
file {
path => "/tmp/solace_logs_parse_failed.log"
codec => rubydebug { "metadata" => "true" }
}
# } else if "ab" == "bc" { # no parsing errors, stick into elastic!
} else { # no parsing errors, stick into elastic!
if [@metadata][event] {
if [@metadata][event] != "auth" {
#elasticsearch {
# hosts => ["localhost:9200"]
# index => "sol-event-%{+YYYY.MM.dd}"
#}
}
if [@metadata][event] == "auth" { # special authentication related event log
file {
path => "/var/log/solace.logstash/%{logsource}/auth.log"
codec => line { format => "%{localdate} <%{severity_label}> %{logsource} %{program}: %{scope}: %{event}: %{message}"}
stale_cleanup_interval => 60
}
} else { # normal event logs
#elasticsearch {
# hosts => ["localhost:9200"]
# index => "sol-event-%{+YYYY.MM.dd}"
#}
file {
path => "/var/log/solace.logstash/%{logsource}/event.log"
codec => line { format => "%{localdate} <%{severity_label}> %{logsource} %{program}: %{scope}: %{event}: %{message}"}
stale_cleanup_interval => 60
}
if [vpn and "seperate logs" == "no thanks"] { # remove the 'and ...' part if you want per-VPN specific logs (super useful on shared brokers, when one noisy VPN rolls all the logs) *** MIGHT RUN INTO LIMITS ON NUMBER OF OPEN FILES!!!
file {
path => "/var/log/solace.logstash/%{logsource}/%{vpn}/event.log"
codec => line { format => "%{localdate} <%{severity_label}> %{logsource} %{program}: %{scope}: %{event}: %{message}"}
stale_cleanup_interval => 60
}
}
}
if [@metadata][alert] {
file {
path => "/var/log/solace.logstash/alerts.log"
codec => line { format => "%{localdate} <%{severity_label}> %{logsource} %{program}: %{scope}: %{event}: %{message}"}
stale_cleanup_interval => 60
}
}
} else if [@metadata][command] == "show" {
#elasticsearch {
# hosts => ["localhost:9200"]
# index => "sol-cmd-show-%{+YYYY.MM.dd}"
#}
file {
path => "/var/log/solace.logstash/%{logsource}/show.log"
codec => line { format => "%{localdate} %{logsource} %{program}: %{message}"}
stale_cleanup_interval => 60
}
} else if [@metadata][command] == "config" {
#elasticsearch {
# hosts => ["localhost:9200"]
# index => "sol-cmd-cfg-%{+YYYY.MM.dd}"
#}
if [@metadata][fileoutput] == "true" {
file {
path => "/var/log/solace.logstash/%{logsource}/command.log"
codec => line { format => "%{localdate} %{logsource} %{program}: %{message}"}
stale_cleanup_interval => 60
}
}
} else if [@metadata][system] {
if [@metadata][fileoutput] == "true" {
file {
path => "/var/log/solace.logstash/%{logsource}/system.log"
codec => line { format => "%{localdate} <%{severity_label}> %{logsource} %{program}: %{message}"}
stale_cleanup_interval => 60
}
}
} else { # something went wrong, didn't match any of my expected types
file {
path => "/tmp/solace_other_no_match.log"
codec => rubydebug { "metadata" => "true" }
}
}
}
# this will log full entries into /tmp
if [@metadata][debug] == "true" {
if [@metadata][event] {
file {
path => "/tmp/solace.event.log"
codec => rubydebug { "metadata" => "true" }
stale_cleanup_interval => 60
}
} else if [@metadata][command] {
file {
path => "/tmp/solace.command.log"
codec => rubydebug { "metadata" => "true" }
stale_cleanup_interval => 60
}
} else if [@metadata][system] {
file {
path => "/tmp/solace.system.log"
codec => rubydebug { "metadata" => "true" }
stale_cleanup_interval => 60
}
} else {
file {
path => "/tmp/solace.unclassified.log"
codec => rubydebug { "metadata" => "true" }
}
}
}
}