mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Logs: Fix total bytes process calculation (#24691)
- log stats for Loki are per query - this change tracks the query stats by refId, preventing the summing of the same stats across multiple series of the same response.
This commit is contained in:
parent
405145fdd3
commit
25e1238022
@ -384,14 +384,20 @@ export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefi
|
||||
|
||||
// Hack to print loki stats in Explore. Should be using proper stats display via drawer in Explore (rework in 7.1)
|
||||
let totalBytes = 0;
|
||||
const queriesVisited: { [refId: string]: boolean } = {};
|
||||
for (const series of logSeries) {
|
||||
const totalBytesKey = series.meta?.custom?.lokiQueryStatKey;
|
||||
// Stats are per query, keeping track by refId
|
||||
const { refId } = series;
|
||||
if (refId && !queriesVisited[refId]) {
|
||||
if (totalBytesKey && series.meta.stats) {
|
||||
const byteStat = series.meta.stats.find(stat => stat.displayName === totalBytesKey);
|
||||
if (byteStat) {
|
||||
totalBytes += byteStat.value;
|
||||
}
|
||||
}
|
||||
queriesVisited[refId] = true;
|
||||
}
|
||||
}
|
||||
if (totalBytes > 0) {
|
||||
const { text, suffix } = decimalSIPrefix('B')(totalBytes);
|
||||
|
Loading…
Reference in New Issue
Block a user