Skip to content

Commit

Permalink
feat(comms): add support for the Grafana/Loki log engine
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jeclrsg committed Sep 20, 2024
1 parent 8600273 commit 43b7403
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/comms/src/services/wsLogaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 43b7403

Please sign in to comment.