mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 17:06:57 -06:00
Logs: Let level
label take precedence over detected_level
(#96678)
This commit is contained in:
parent
bf74b9c9c0
commit
f44bc2bfd8
@ -45,7 +45,7 @@ export function parseLegacyLogsFrame(frame: DataFrame): LogsFrame | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const timeNanosecondField = cache.getFieldByName('tsNs') ?? 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;
|
const idField = cache.getFieldByName('id') ?? null;
|
||||||
|
|
||||||
// extracting the labels is done very differently for old-loki-style and simple-style
|
// extracting the labels is done very differently for old-loki-style and simple-style
|
||||||
|
@ -426,7 +426,7 @@ export function logSeriesToLogsModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let logLevel = LogLevel.unknown;
|
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') {
|
if (typeof logLevelKey === 'number' || typeof logLevelKey === 'string') {
|
||||||
logLevel = getLogLevelFromKey(logLevelKey);
|
logLevel = getLogLevelFromKey(logLevelKey);
|
||||||
} else {
|
} else {
|
||||||
@ -643,7 +643,7 @@ function defaultExtractLevel(dataFrame: DataFrame): LogLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLogLevelFromLabels(labels: Labels): 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;
|
return level ? getLogLevelFromKey(level) : LogLevel.unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ export function extractLevelLikeLabelFromDataFrame(frame: DataFrame): string | n
|
|||||||
// Find first level-like label
|
// Find first level-like label
|
||||||
for (let labels of labelsArray) {
|
for (let labels of labelsArray) {
|
||||||
const label = Object.keys(labels).find(
|
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) {
|
if (label) {
|
||||||
levelLikeLabel = label;
|
levelLikeLabel = label;
|
||||||
|
Loading…
Reference in New Issue
Block a user