mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix hiding of series in table if labels have number values (#30185)
* Fix summing of label names for Loki * Add test
This commit is contained in:
parent
0d9dbcf7fa
commit
f9ba87f1c8
@ -1,5 +1,12 @@
|
||||
import { CircularDataFrame, FieldCache, FieldType, MutableDataFrame } from '@grafana/data';
|
||||
import { LokiStreamResult, LokiTailResponse, LokiStreamResponse, LokiResultType, TransformerOptions } from './types';
|
||||
import {
|
||||
LokiStreamResult,
|
||||
LokiTailResponse,
|
||||
LokiStreamResponse,
|
||||
LokiResultType,
|
||||
TransformerOptions,
|
||||
LokiMatrixResult,
|
||||
} from './types';
|
||||
import * as ResultTransformer from './result_transformer';
|
||||
import { enhanceDataFrame, lokiPointsToTimeseriesPoints } from './result_transformer';
|
||||
import { setTemplateSrv } from '@grafana/runtime';
|
||||
@ -209,6 +216,20 @@ describe('loki result transformer', () => {
|
||||
expect(label).toBe('label1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('lokiResultsToTableModel', () => {
|
||||
it('should correctly set the type of the label column to be a string', () => {
|
||||
const lokiResultWithIntLabel = ([
|
||||
{ metric: { test: 1 }, value: [1610367143, 10] },
|
||||
{ metric: { test: 2 }, value: [1610367144, 20] },
|
||||
] as unknown) as LokiMatrixResult[];
|
||||
|
||||
const table = ResultTransformer.lokiResultsToTableModel(lokiResultWithIntLabel, 1, 'A', {});
|
||||
expect(table.columns[0].type).toBe('time');
|
||||
expect(table.columns[1].type).toBe('string');
|
||||
expect(table.columns[2].type).toBe('number');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('enhanceDataFrame', () => {
|
||||
|
@ -240,7 +240,7 @@ export function lokiResultsToTableModel(
|
||||
table.meta = meta;
|
||||
table.columns = [
|
||||
{ text: 'Time', type: FieldType.time },
|
||||
...sortedLabels.map(label => ({ text: label, filterable: true })),
|
||||
...sortedLabels.map(label => ({ text: label, filterable: true, type: FieldType.string })),
|
||||
{ text: resultCount > 1 || valueWithRefId ? `Value #${refId}` : 'Value', type: FieldType.number },
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user