-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlogstash-obi-clickstream.conf
200 lines (182 loc) · 9.99 KB
/
logstash-obi-clickstream.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
# @rmoff / December 2016
#
# For full details about this script see https://github.com/RittmanMead/obi-enhanced-usage-tracking/
#
# -----------------------------------------------------------------------------------------------
#
# The MIT License (MIT)
# Copyright (c) 2016 Rittman Mead Consulting Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# -----------------------------------------------------------------------------------------------
input {
file {
# If set to "beginning" logstash will start at the beginning of the file, that is, process what
# is there AND then start tailing it for new content. If end (the default) it just tails the file
# and ignores existing content
#
# If you want to *re-process* a file that logstash has already processed then you need to remove the
# sincedb related to it, by default in ~/.sincedb*
#
start_position => beginning
path => ["/app/oracle/biee/user_projects/domains/bi/servers/obips1/logs/rm_http*.log"]
type => "OracleBIPresentationServicesComponent"
}
}
filter {
if [file] !~ /.+/ {
mutate {add_field => {file => "%{path}"} }
}
multiline {
# This is TIMESTAMP_ISO8601, distilled down from the regex templates in logstash/patterns/grok-logstash/patterns
pattern => "^\[(\d\d){1,2}-(?:0?[1-9]|1[0-2])-(?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9])[T ](?:2[0123]|[01]?[0-9]):?(?:[0-5][0-9])(?::?(?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?))?(?:Z|[+-](?:2[0123]|[01]?[0-9])(?::?(?:[0-5][0-9])))?\]"
# If a line does not begin with the timestamp, then assume it is part of the previous log message
negate => true
what => "previous"
}
# This took me a while to figure http://stackoverflow.com/a/22193252 -- grok doesn't like \n
mutate { gsub => ['message', "\n", "--NL--"] }
# Different OBI deployments have different CRLF combos, let's unify them
mutate { gsub => ['message', "\r--NL--", "--NL--"] }
mutate { gsub => ['message', "\r", ""] }
# exclude records with no log content (eg top of file)
if [message] == "--NL--" {
# mutate { add_tag => ["drop"]}
drop {}
}
# Save yourself tons of time and use this for perfecting grok statements: http://grokdebug.herokuapp.com/
grok {
break_on_match => true
match => [
"message", "\[%{TIMESTAMP_ISO8601:timestamp}\] \[%{DATA:Component}\] \[%{WORD:Severity}(:%{NUMBER:LogLevelNum})?\] \[%{DATA:InternalUser}\] \[%{DATA:internal-component}\] \[ecid: %{DATA:ECID}\] \[tid: %{DATA:TID}\] %{GREEDYDATA:message}"
]
overwrite => ["message"]
tag_on_failure => ["_grokparsefailure","grok01"]
}
# Scrape out all we can from the message
if [internal-component] == "saw.httpserver.request.showrequest" {
mutate { add_tag => "http"}
grok {
break_on_match => false
match => [
"message","Action='%{DATA:saw_http_Action}',"
,"message","--NL--Path: %{DATA:saw_http_SAWPath}--NL--"
,"message","--NL--SessionID: %{DATA:saw_http_SessionID}--NL--"
,"message","--NL--task: %{DATA:saw_http_Task}--NL--"
,"message","AuthProps: AuthSchema=.+\|UID=%{DATA:saw_http_UID}\|User=%{DATA:saw_http_user}--NL--"
,"message","CONTENT_TYPE=%{DATA:saw_http_content_type}, "
,"message","Attach=%{DATA:saw_Attach}--NL--"
,"message","Caller='%{WORD:saw_http_caller}',"
,"message","ClientStateXml=%{DATA:saw_http_ClientStateXml}--NL--icharset"
,"message","ColumnExpr=%{DATA:saw_http_ColumnExpr}--NL--"
,"message","ColumnID=%{DATA:saw_http_ColumnID}--NL--"
,"message","Content-Length=%{DATA:saw_http_Req-Content-Length}--NL--"
,"message","Content-Type: %{DATA:saw_http_content_type};"
,"message","DashPagePath: %{DATA:saw_http_DashPagePath}--NL--"
,"message","DashPath: %{DATA:DashPath}--NL--"
,"message","DashboardCaption='%{DATA:saw_http_DashboardCaption}',"
,"message","Done=%{DATA:saw_http_Done}--NL--"
,"message","EditorID=%{DATA:saw_http_EditorID}--NL--"
,"message","Folder=%{DATA:saw_http_Folder}--NL--"
,"message","HTTP_CHUNKED_AWARE=%{DATA:saw_http_HTTP_CHUNKED_AWARE},"
,"message","HttpCommand: %{WORD:saw_http_http_command}"
,"message","IS_SECURE=%{DATA:saw_http_IS_SECURE},"
,"message","ItemName=%{DATA:saw_http_ItemName}--NL--"
,"message","JSESSIONID=%{DATA:saw_http_cookie-JSESSIONID};"
,"message","NQUser=%{DATA:saw_http_NQUser}--NL--"
,"message","ORA_BIPS_LBINFO=%{WORD:saw_http_cookie-ORA_BIPS_LBINFO}"
,"message","ORA_BIPS_NQID=%{WORD:saw_http_cookie-ORA_BIPS_NQID}"
,"message","Page='%{DATA:saw_http_DBPage}',"
,"message","PortalPath=%{DATA:saw_http_PortalPath}--NL--"
,"message","REMOTE_ADDR=%{IPV4:saw_http_REMOTE_ADDR},"
,"message","REMOTE_HOST=%{DATA:saw_http_REMOTE_HOST},"
,"message","RSP: %{DATA:saw_http_RSP}--NL--"
,"message","Referer=%{DATA:saw_http_Referer}--NL--"
,"message","RemoteIP: %{IPV4:saw_http_RemoteIP}"
,"message","ReportEditor:--NL--%{DATA:saw_http_ReportEditor}--NL--"
,"message","ReportEditor=%{DATA:saw_http_ReportEditor}--NL--"
,"message","ReportXML:--NL--%{DATA:saw_http_ReportXML}--NL--icharset"
,"message","Request params:--NL--%{DATA:saw_http_request}--NL--"
,"message","Request received.--NL--Type: %{WORD:saw_http_RequestType}"
,"message","RptPath: %{DATA:saw_http_RptPath}--NL--"
,"message","SCRIPT_NAME=%{DATA:saw_http_SCRIPT_NAME},"
,"message","SERVER_NAME=%{DATA:saw_http_SERVER_NAME},"
,"message","SERVER_PORT=%{DATA:saw_http_SERVER_PORT},"
,"message","SERVER_PROTOCOL=%{DATA:saw_http_SERVER_PROTOCOL},"
,"message","SESSION_COOKIE_SUFFIX=%{DATA:saw_http_SESSION_COOKIE_SUFFIX},"
,"message","SID: %{DATA:saw_http_SID}--NL--"
,"message","SearchID=%{WORD:saw_http_SearchID}--NL--"
,"message","StateAction='%{WORD:saw_http_StateAction}"
,"message","StateID=%{WORD:saw_http_StateID}--NL--"
,"message","StateID=%{WORD:saw_http_StateID}--NL--"
,"message","Status Code: %{NUMBER:Status-code}, Content-Length: %{NUMBER:saw_http_Content-Length}"
,"message","Style=%{WORD:saw_Style}--NL--"
,"message","SubjectArea=\"%{DATA:saw_http_subjectArea}\"--NL--"
,"message","ThreadID: %{WORD:saw_http_ThreadID}--NL--"
,"message","ThreadID: '%{WORD:saw_http_ThreadID}',"
,"message","URL=%{DATA:saw_http_URL}\["
,"message","UpdateAnswerTree:--NL--%{DATA:saw_http_UpdateAnswerTree}--NL--"
,"message","UpdateAnswerTree=%{WORD:saw_http_ViewState}"
,"message","User-Agent=%{DATA:saw_http_User-Agent}--NL--"
,"message","ViewID=%{DATA:saw_http_ViewID}--NL--"
,"message","ViewState=%{WORD:saw_http_ViewState}"
,"message","X-Forwarded-For=%{DATA:saw_http_X-Forwarded-For}--NL--"
,"message","_scid='%{DATA:saw_http__scid}''"
,"message","action=%{DATA:saw_http_path}--NL--"
,"message","ecid: %{DATA:saw_http_ecid}--NL--"
,"message","fmapId='%{WORD:saw_http_fmapId}',"
,"message","iBotPath: %{DATA:saw_http_iBotPath}--NL--"
,"message","iBotSessionID: %{DATA:saw_http_iBotSessionID}--NL--"
,"message","page='%{DATA:saw_http_DBPage}',"
,"message","path=%{DATA:saw_http_path}--NL--"
,"message","reloadTargets=%{WORD:saw_http_reloadTargets}"
,"message","sqlColumnName=%{WORD:saw_http_sqlColumnName}--NL--"
,"message","table=\"%{DATA:saw_http_SATable}\"--NL--"
,"message","tableKey=%{DATA:saw_http_SATableKey}--NL--"
,"message","viewEditor=%{DATA:saw_http_ViewEditor}--NL--"
,"message","viewID=%{DATA:saw_http_ViewID}--NL--"
]
tag_on_failure => []
}
# Look up the geographical location for the client IP
geoip { source => "saw_http_RemoteIP"}
# TODO urldecode the portalpath etc from the HTTP data here
# Enrich the user agent data
if [saw_http_User-Agent] =~ /iphone/ or [saw_http_User-Agent] =~ /ipad/ or [saw_http_User-Agent] =~ /Mobile/ or [saw_http_User-Agent] =~ /Android/ {
mutate {add_field => {"mobile" => 1}}
} else {
mutate {add_field => {"mobile" => 0}}
}
useragent { source => "saw_http_User-Agent" target => "ua"}
if [ua][[major] =~ /.+/ {
mutate {add_field => {useragent => "%{[ua][name]} %{[ua][major]}.%{[ua][minor]}"} }
}
}
# --------------------------
# Set the time of the event to that of the log entry
date {
match => ["timestamp", "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", "yyyy-MM-dd'T'HH:mm:ssZZ","MMM dd, yyyy hh:mm:ss a","dd/MMM/yyyy:HH:mm:ss Z"]
}
mutate { remove_field => ["timestamp"]}
mutate { uppercase => ["severity"]}
mutate { gsub => ['ora-message', "--NL--", " "] }
mutate { gsub => ['message', "--NL--", " "] }
mutate { gsub => ['main_message', "--NL--", " "] }
mutate { gsub => ['additional_message_data', "--NL--", " "] }
mutate { gsub => ['stack', "--NL--", "/"] }
mutate { gsub => ['stack', "\t", ""] }
}
output {
if "_grokparsefailure" not in [tags] {
# elasticsearch { hosts => "localhost" index => "logstash-obiee-%{+YYYY.MM.dd}" }
if [type] == "OracleBIPresentationServicesComponent" and "http" in [tags] {
# stdout { codec => rubydebug }
csv { fields => ["@timestamp", "saw_http_cookie-ORA_BIPS_NQID","saw_http_user", "saw_http_SessionID","saw_http_ecid", "saw_http_RequestType","saw_http_request","saw_http_Folder","saw_http_ItemName","saw_http_EditorID","saw_http_ReportEditor","saw_http_subjectArea","saw_http_SATable","saw_http_Action","useragent","mobile"]
path => "~/obi-clickdata/http_requests.csv"}
}
}
}