mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 13:39:19 -06:00
loki: dataframes: do not set field.config.DisplayName (#49317)
This commit is contained in:
parent
15605b6c80
commit
061055fac9
@ -369,7 +369,7 @@ describe('LokiDatasource', () => {
|
||||
const dataFrame = result.data[0] as DataFrame;
|
||||
const fieldCache = new FieldCache(dataFrame);
|
||||
|
||||
expect(fieldCache.getFieldByName('line')?.values.get(0)).toBe('hello');
|
||||
expect(fieldCache.getFieldByName('Line')?.values.get(0)).toBe('hello');
|
||||
expect(dataFrame.meta?.limit).toBe(20);
|
||||
expect(dataFrame.meta?.searchWords).toEqual(['foo']);
|
||||
});
|
||||
|
@ -765,7 +765,7 @@ export class LokiDatasource
|
||||
const splitKeys: string[] = tagKeys.split(',').filter((v: string) => v !== '');
|
||||
|
||||
for (const frame of data) {
|
||||
const view = new DataFrameView<{ ts: string; line: string; labels: Labels }>(frame);
|
||||
const view = new DataFrameView<{ Time: string; Line: string; labels: Labels }>(frame);
|
||||
|
||||
view.forEach((row) => {
|
||||
const { labels } = row;
|
||||
@ -791,9 +791,9 @@ export class LokiDatasource
|
||||
const tags = Array.from(new Set(maybeDuplicatedTags));
|
||||
|
||||
annotations.push({
|
||||
time: new Date(row.ts).valueOf(),
|
||||
time: new Date(row.Time).valueOf(),
|
||||
title: renderLegendFormat(titleFormat, labels),
|
||||
text: renderLegendFormat(textFormat, labels) || row.line,
|
||||
text: renderLegendFormat(textFormat, labels) || row.Line,
|
||||
tags,
|
||||
});
|
||||
});
|
||||
|
@ -48,10 +48,10 @@ describe('Live Stream Tests', () => {
|
||||
const view = new DataFrameView(val[0]);
|
||||
const last = { ...view.get(view.length - 1) };
|
||||
expect(last).toEqual({
|
||||
ts: '2019-08-28T20:50:40.118Z',
|
||||
Time: '2019-08-28T20:50:40.118Z',
|
||||
tsNs: '1567025440118944705',
|
||||
id: '25d81461-a66f-53ff-98d5-e39515af4735_A',
|
||||
line: 'Kittens',
|
||||
Line: 'Kittens',
|
||||
labels: { filename: '/var/log/sntpc.log' },
|
||||
});
|
||||
},
|
||||
@ -148,8 +148,8 @@ describe('Live Stream Tests', () => {
|
||||
const firstLog = { ...view.get(0) };
|
||||
const secondLog = { ...view.get(1) };
|
||||
|
||||
expect(firstLog.line).toBe('Kittens');
|
||||
expect(secondLog.line).toBe('Doggos');
|
||||
expect(firstLog.Line).toBe('Kittens');
|
||||
expect(secondLog.Line).toBe('Doggos');
|
||||
expect(retries).toBe(2);
|
||||
});
|
||||
});
|
||||
|
@ -33,10 +33,10 @@ export class LiveStreams {
|
||||
|
||||
const data = new CircularDataFrame({ capacity: target.size });
|
||||
data.addField({ name: 'labels', type: FieldType.other }); // The labels for each line
|
||||
data.addField({ name: 'ts', type: FieldType.time, config: { displayName: 'Time' } });
|
||||
data.addField({ name: 'line', type: FieldType.string }).labels = parseLabels(target.query);
|
||||
data.addField({ name: 'Time', type: FieldType.time, config: {} });
|
||||
data.addField({ name: 'Line', type: FieldType.string }).labels = parseLabels(target.query);
|
||||
data.addField({ name: 'id', type: FieldType.string });
|
||||
data.addField({ name: 'tsNs', type: FieldType.time, config: { displayName: 'Time ns' } });
|
||||
data.addField({ name: 'tsNs', type: FieldType.time, config: {} });
|
||||
data.meta = { ...data.meta, preferredVisualisationType: 'logs' };
|
||||
data.refId = target.refId;
|
||||
|
||||
|
@ -242,7 +242,7 @@ describe('loki result transformer', () => {
|
||||
|
||||
describe('enhanceDataFrame', () => {
|
||||
it('adds links to fields', () => {
|
||||
const df = new MutableDataFrame({ fields: [{ name: 'line', values: ['nothing', 'trace1=1234', 'trace2=foo'] }] });
|
||||
const df = new MutableDataFrame({ fields: [{ name: 'Line', values: ['nothing', 'trace1=1234', 'trace2=foo'] }] });
|
||||
ResultTransformer.enhanceDataFrame(df, {
|
||||
derivedFields: [
|
||||
{
|
||||
|
@ -92,9 +92,9 @@ function constructDataFrame(
|
||||
refId,
|
||||
fields: [
|
||||
{ name: 'labels', type: FieldType.other, config: {}, values: labels },
|
||||
{ name: 'ts', type: FieldType.time, config: { displayName: 'Time' }, values: times }, // Time
|
||||
{ name: 'line', type: FieldType.string, config: {}, values: lines }, // Line - needs to be the first field with string type
|
||||
{ name: 'tsNs', type: FieldType.time, config: { displayName: 'Time ns' }, values: timesNs }, // Time
|
||||
{ name: 'Time', type: FieldType.time, config: {}, values: times }, // Time
|
||||
{ name: 'Line', type: FieldType.string, config: {}, values: lines }, // Line - needs to be the first field with string type
|
||||
{ name: 'tsNs', type: FieldType.time, config: {}, values: timesNs }, // Time
|
||||
{ name: 'id', type: FieldType.string, config: {}, values: uids },
|
||||
],
|
||||
length: times.length,
|
||||
@ -391,9 +391,9 @@ export const enhanceDataFrame = (dataFrame: DataFrame, config: LokiOptions | nul
|
||||
const newFields = Object.values(derivedFieldsGrouped).map(fieldFromDerivedFieldConfig);
|
||||
|
||||
const view = new DataFrameView(dataFrame);
|
||||
view.forEach((row: { line: string }) => {
|
||||
view.forEach((row: { Line: string }) => {
|
||||
for (const field of newFields) {
|
||||
const logMatch = row.line.match(derivedFieldsGrouped[field.name][0].matcherRegex);
|
||||
const logMatch = row.Line.match(derivedFieldsGrouped[field.name][0].matcherRegex);
|
||||
field.values.add(logMatch && logMatch[1]);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user