logs collector updated

This commit is contained in:
bvn13 2024-09-02 23:06:39 +03:00
parent 9c1a3f230f
commit acc041e1c3

View File

@ -20,9 +20,9 @@ transforms:
source: >- source: >-
l = . l = .
log("!!! 1", level:"info", rate_limit_secs:0) #log("!!! 1", level:"info", rate_limit_secs:0)
log(l, level:"info", rate_limit_secs:0) #log(l, level:"info", rate_limit_secs:0)
.app = {} .app = {}
@ -44,7 +44,7 @@ transforms:
.app.body = "" .app.body = ""
log("!!! 2", level:"info") #log("!!! 2", level:"info")
m = if (exists(.message)) { m = if (exists(.message)) {
to_string!(.message) to_string!(.message)
@ -55,7 +55,7 @@ transforms:
msg, err = parse_json(m) msg, err = parse_json(m)
if (err == null) { if (err == null) {
log("!!! 2.1: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1: {{m}}", level:"info", rate_limit_secs:0)
.app.body = if (exists(msg.message)) { .app.body = if (exists(msg.message)) {
msg.message msg.message
@ -63,7 +63,7 @@ transforms:
m m
} }
log("!!! 2.1.1: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.1: {{m}}", level:"info", rate_limit_secs:0)
trace = if (exists(msg.message)) { trace = if (exists(msg.message)) {
msgjson, e = parse_regex(msg.message, r'request_id=(?P<trace_id>\S+)') msgjson, e = parse_regex(msg.message, r'request_id=(?P<trace_id>\S+)')
@ -77,7 +77,7 @@ transforms:
{} {}
} }
log("!!! 2.1.2: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.2: {{m}}", level:"info", rate_limit_secs:0)
.app.trace_id = if (exists(trace.trace_id) && trace.trace_id != "") { .app.trace_id = if (exists(trace.trace_id) && trace.trace_id != "") {
trace.trace_id trace.trace_id
@ -87,7 +87,7 @@ transforms:
"" ""
} }
log("!!! 2.1.3: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.3: {{m}}", level:"info", rate_limit_secs:0)
.app.trace_id = if (exists(.app.trace_id) && .app.trace_id != null && .app.trace_id != "") { .app.trace_id = if (exists(.app.trace_id) && .app.trace_id != null && .app.trace_id != "") {
span = parse_regex!(.app.trace_id, r'(?<a1>\w+)-(?<a2>\w+)-(?<a3>\w+)-(?<a4>\w+)-(?<a5>\w+)') span = parse_regex!(.app.trace_id, r'(?<a1>\w+)-(?<a2>\w+)-(?<a3>\w+)-(?<a4>\w+)-(?<a5>\w+)')
@ -107,7 +107,7 @@ transforms:
"" ""
} }
log("!!! 2.1.4: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.4: {{m}}", level:"info", rate_limit_secs:0)
.app.severity_text = if (exists(msg.level)) { .app.severity_text = if (exists(msg.level)) {
s, e = to_string(msg.level) s, e = to_string(msg.level)
@ -121,7 +121,7 @@ transforms:
"INFO" "INFO"
} }
log("!!! 2.1.5: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.5: {{m}}", level:"info", rate_limit_secs:0)
.app.severity_number = if (exists(msg.level_value)) { .app.severity_number = if (exists(msg.level_value)) {
i, e = to_int(msg.level_value) i, e = to_int(msg.level_value)
@ -133,11 +133,11 @@ transforms:
} }
} }
log("!!! 2.1.6: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.6: {{m}}", level:"info", rate_limit_secs:0)
.app.attributes.message = msg .app.attributes.message = msg
log("!!! 2.1.7: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.7: {{m}}", level:"info", rate_limit_secs:0)
.app.attributes.logger_name = if (exists(msg.logger_name)) { .app.attributes.logger_name = if (exists(msg.logger_name)) {
msg.logger_name msg.logger_name
@ -145,7 +145,7 @@ transforms:
"none" "none"
} }
log("!!! 2.1.8: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.8: {{m}}", level:"info", rate_limit_secs:0)
.app.attributes._timestamp = if (exists(msg.@timestamp)) { .app.attributes._timestamp = if (exists(msg.@timestamp)) {
msg.@timestamp msg.@timestamp
@ -153,7 +153,7 @@ transforms:
now() now()
} }
log("!!! 2.1.9: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.9: {{m}}", level:"info", rate_limit_secs:0)
.app.attributes.thread_name = if (exists(msg.thread_name)) { .app.attributes.thread_name = if (exists(msg.thread_name)) {
msg.thread_name msg.thread_name
@ -161,23 +161,22 @@ transforms:
"none" "none"
} }
log("!!! 2.1.10: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.10: {{m}}", level:"info", rate_limit_secs:0)
.app.attributes.hostname = "$HOSTNAME" .app.attributes.hostname = "$HOSTNAME"
log("!!! 2.1.11: {{m}}", level:"info", rate_limit_secs:0) #log("!!! 2.1.11: {{m}}", level:"info", rate_limit_secs:0)
.app.attributes.app_name = "${APP_NAME?Specify env.APP_NAME}" .app.attributes.app_name = "${APP_NAME?Specify env.APP_NAME}"
} else { } else {
log("!!! 2.2: {{m}}", level:"warn", rate_limit_secs:0) #log("!!! 2.2: {{m}}", level:"warn", rate_limit_secs:0)
.app.body = m .app.body = m
log(err, level:"error", rate_limit_secs:0) #log(err, level:"error", rate_limit_secs:0)
} }
log("!!! 3", level:"warn", rate_limit_secs:0) #log("!!! 3", level:"warn", rate_limit_secs:0)
del(.message) del(.message)