From 43b7403b8a0cfcd59846d5dbc23fc794eaa3b905 Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:10:05 -0400 Subject: [PATCH] feat(comms): add support for the Grafana/Loki log engine recognizes the grafana engine manager type, also reduces arrays of log fields down into single objects: the elastic & log analytics (LA) engines return rows formatted like: { lines: [{ fields: [ { timestamp: "...", container: "...", ...}, ] }] } and the loki engine currently returns rows formatted like: (separate objects per field) { lines: [{ fields: [ { tsNs: "..." }, { pod: "..."}, { log: "..." } ] }] } so just forcing the loki engine results to look like the elastic & LA Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- packages/comms/src/services/wsLogaccess.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/comms/src/services/wsLogaccess.ts b/packages/comms/src/services/wsLogaccess.ts index b1e971e5db..59bfdcb55d 100644 --- a/packages/comms/src/services/wsLogaccess.ts +++ b/packages/comms/src/services/wsLogaccess.ts @@ -82,7 +82,11 @@ export class LogaccessService extends LogaccessServiceBase { const convertLogLine = (line: any) => { const retVal: LogLine = {}; for (const key in columnMap) { - retVal[key] = line?.fields[0][columnMap[key]] ?? ""; + if (line?.fields) { + retVal[key] = Object.assign({}, ...line.fields)[columnMap[key]] ?? ""; + } else { + retVal[key] = ""; + } } return retVal; }; @@ -236,6 +240,7 @@ export class LogaccessService extends LogaccessServiceBase { switch (logInfo.RemoteLogManagerType) { case "azureloganalyticscurl": case "elasticstack": + case "grafanacurl": lines = logLines.lines?.map(convertLogLine) ?? []; break; default: