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:
Ivana Huckova
2021-01-14 15:47:18 +01:00
committed by GitHub
parent 0d9dbcf7fa
commit f9ba87f1c8
2 changed files with 23 additions and 2 deletions

View File

@@ -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', () => {