Logs: Let level label take precedence over detected_level (#96678)

This commit is contained in:
Sven Grossmann 2024-11-19 16:55:05 +01:00 committed by GitHub
parent bf74b9c9c0
commit f44bc2bfd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -45,7 +45,7 @@ export function parseLegacyLogsFrame(frame: DataFrame): LogsFrame | null {
}
const timeNanosecondField = cache.getFieldByName('tsNs') ?? null;
const severityField = cache.getFieldByName('detected_level') ?? cache.getFieldByName('level') ?? null;
const severityField = cache.getFieldByName('level') ?? cache.getFieldByName('detected_level') ?? null;
const idField = cache.getFieldByName('id') ?? null;
// extracting the labels is done very differently for old-loki-style and simple-style

View File

@ -426,7 +426,7 @@ export function logSeriesToLogsModel(
}
let logLevel = LogLevel.unknown;
const logLevelKey = (logLevelField && logLevelField.values[j]) || (labels?.detected_level ?? labels?.level);
const logLevelKey = (logLevelField && logLevelField.values[j]) || (labels?.level ?? labels?.detected_level);
if (typeof logLevelKey === 'number' || typeof logLevelKey === 'string') {
logLevel = getLogLevelFromKey(logLevelKey);
} else {
@ -643,7 +643,7 @@ function defaultExtractLevel(dataFrame: DataFrame): LogLevel {
}
function getLogLevelFromLabels(labels: Labels): LogLevel {
const level = labels['detected_level'] ?? labels['level'] ?? labels['lvl'] ?? labels['loglevel'] ?? '';
const level = labels['level'] ?? labels['detected_level'] ?? labels['lvl'] ?? labels['loglevel'] ?? '';
return level ? getLogLevelFromKey(level) : LogLevel.unknown;
}

View File

@ -122,7 +122,7 @@ export function extractLevelLikeLabelFromDataFrame(frame: DataFrame): string | n
// Find first level-like label
for (let labels of labelsArray) {
const label = Object.keys(labels).find(
(label) => label === 'detected_level' || label === 'level' || label === 'lvl' || label.includes('level')
(label) => label === 'level' || label === 'detected_level' || label === 'lvl' || label.includes('level')
);
if (label) {
levelLikeLabel = label;