From 6b85ba2ead81c6882f3229337c2fd312eda61311 Mon Sep 17 00:00:00 2001 From: pajama-coder Date: Wed, 27 Nov 2024 12:23:53 +0800 Subject: [PATCH] Fixed the wrong body format for logging to Splunk --- agent/apps/ztm/proxy/api.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/agent/apps/ztm/proxy/api.js b/agent/apps/ztm/proxy/api.js index f23a5e5..d481fec 100644 --- a/agent/apps/ztm/proxy/api.js +++ b/agent/apps/ztm/proxy/api.js @@ -161,15 +161,17 @@ export default function ({ app, mesh }) { .handleMessageEnd( (msg) => { currentLogger?.log?.({ - time: $requestTime.toUTCString(), - username: $ctx.peer.username, - endpoint: $ctx.peer.id, - ip: $ctx.peer.ip, - target: $target, - method: $requestHead.method, - path: $requestHead.path, - headers: $requestHead.headers, - size: msg.tail.headSize + msg.tail.bodySize, + event: { + time: $requestTime.toUTCString(), + username: $ctx.peer.username, + endpoint: $ctx.peer.id, + ip: $ctx.peer.ip, + target: $target, + method: $requestHead.method, + path: $requestHead.path, + headers: $requestHead.headers, + size: msg.tail.headSize + msg.tail.bodySize, + } }) } )