Skip to content

Commit

Permalink
fix(comms): GetLogs use WsLogaccess.LogAccessType
Browse files Browse the repository at this point in the history
If the fields returned by WsLogaccess.GetLogAccessInfo exist in
WsLogaccess.LogAccessType, have the filter use those categories,
otherwise use the field defined by the log engine in the column map.

This is a preliminary attempt at support for the Grafana Loki engine.

Also, fixes an issue where searching by container name wouldn't return
any log messages for ephemeral containers, eg "hthor-job-W2024..." as
well as "hthor"

Signed-off-by: Jeremy Clements <[email protected]>
  • Loading branch information
jeclrsg committed Jul 19, 2024
1 parent 439240f commit 498ffa6
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions packages/comms/src/services/wsLogaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,57 @@ export class LogaccessService extends LogaccessServiceBase {
for (const key in request) {
let searchField;
if (key in columnMap) {
searchField = columnMap[key];
if (Object.values(WsLogaccess.LogColumnType).includes(key as WsLogaccess.LogColumnType)) {
searchField = key;
} else {
searchField = columnMap[key];
}
}
let logCategory = WsLogaccess.LogAccessType.ByFieldName;
let logCategory;
if (searchField) {
switch (searchField) {
case WsLogaccess.LogColumnType.workunits:
case "hpcc.log.jobid":
logCategory = WsLogaccess.LogAccessType.ByJobID;
break;
case WsLogaccess.LogColumnType.audience:
case "hpcc.log.audience":
logCategory = WsLogaccess.LogAccessType.ByTargetAudience;
break;
case WsLogaccess.LogColumnType.class:
case "hpcc.log.class":
logCategory = WsLogaccess.LogAccessType.ByLogType;
break;
case WsLogaccess.LogColumnType.components:
case "kubernetes.container.name":
logCategory = WsLogaccess.LogAccessType.ByComponent;
break;
default:
logCategory = WsLogaccess.LogAccessType.ByFieldName;
searchField = columnMap[key];
}
if (Array.isArray(request[key])) {
request[key].forEach(value => {
if (logCategory === WsLogaccess.LogAccessType.ByComponent) {
value += "*";
}
filters.push({
LogCategory: logCategory,
SearchField: searchField,
SearchByValue: value
});
});
} else {
let value = request[key];
if (logCategory === WsLogaccess.LogAccessType.ByComponent) {
// append wildcard to end of search value to include ephemeral
// containers that aren't listed in ECL Watch's filters
value += "*";
}
filters.push({
LogCategory: logCategory,
SearchField: searchField,
SearchByValue: request[key]
SearchByValue: value
});
}
}
Expand Down

0 comments on commit 498ffa6

Please sign in to comment.