glutenfree
Version:
A profiler/loganalyzer for nginx/Cetrea Aw.
35 lines (33 loc) • 1.25 kB
text/coffeescript
class AwLogLineParser
parse: (line) ->
#07:49:40.577 [qtp639880482-16] INFO com.cetrea.anywhere.AnywhereService - Inbound request: 10.226.22.118 - GET - /partial/beds/byorganization/688369/dddddd-dddd
re = /(\d{2}:\d{2}:\d{2}\.\d{3})\s+(\[.+\])\s+(\S+)\s+(\S+)\s+-\s+.*:\s+([\d\.]+)\s+-\s+(\S+)\s+-(.+)/i
m = line.match(re)
if m?
[__, time, thread, level, clazz, ip, method, path] = m
r = path.split("/")
if r?.length > 2
if r[2].indexOf(".") > 0 # if 3rd element in path looks like version
[__, action, component, componentVersion, endpoint, fun, args...] = r
else
[__, action, endpoint, fun, args...] = r
# return
url = [action, component, componentVersion, endpoint, fun].filter((c) -> c?).concat(args).join("/")
{
variables:
ip: ip
time: time
thread: thread
method: method
component: component
componentVersion: componentVersion
action: action
endpoint: endpoint
fun: fun
args: args.join("/")
url: url
id: method + " " + url
}
else false
else false
exports.parser = new AwLogLineParser()