2021-09-17 06:39:26 -05:00
|
|
|
import { DataFrame, FieldType, DataQueryRequest, DataQueryResponse, MutableDataFrame } from '@grafana/data';
|
2021-10-15 06:37:27 -05:00
|
|
|
import { transform, transformV2, transformDFToTable } from './result_transformer';
|
2021-09-17 06:39:26 -05:00
|
|
|
import { PromQuery } from './types';
|
2018-03-12 09:13:05 -05:00
|
|
|
|
2021-01-15 09:20:20 -06:00
|
|
|
jest.mock('@grafana/runtime', () => ({
|
|
|
|
getTemplateSrv: () => ({
|
|
|
|
replace: (str: string) => str,
|
|
|
|
}),
|
|
|
|
getDataSourceSrv: () => {
|
|
|
|
return {
|
|
|
|
getInstanceSettings: () => {
|
|
|
|
return { name: 'Tempo' };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2020-12-01 03:36:38 -06:00
|
|
|
const matrixResponse = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
|
|
|
values: [
|
|
|
|
[1, '10'],
|
|
|
|
[2, '0'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-12 09:13:05 -05:00
|
|
|
describe('Prometheus Result Transformer', () => {
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('transformV2', () => {
|
|
|
|
it('results with time_series format should be enriched with preferredVisualisationType', () => {
|
2021-10-15 06:37:27 -05:00
|
|
|
const request = ({
|
2021-09-17 06:39:26 -05:00
|
|
|
targets: [
|
2018-03-12 09:13:05 -05:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
format: 'time_series',
|
|
|
|
refId: 'A',
|
2018-03-12 09:13:05 -05:00
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
],
|
|
|
|
} as unknown) as DataQueryRequest<PromQuery>;
|
|
|
|
const response = ({
|
|
|
|
state: 'Done',
|
|
|
|
data: [
|
2018-03-12 09:13:05 -05:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
fields: [],
|
|
|
|
length: 2,
|
|
|
|
name: 'ALERTS',
|
|
|
|
refId: 'A',
|
2018-03-12 09:13:05 -05:00
|
|
|
},
|
|
|
|
],
|
2021-09-17 06:39:26 -05:00
|
|
|
} as unknown) as DataQueryResponse;
|
2021-10-15 06:37:27 -05:00
|
|
|
const series = transformV2(response, request, {});
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(series).toEqual({
|
|
|
|
data: [{ fields: [], length: 2, meta: { preferredVisualisationType: 'graph' }, name: 'ALERTS', refId: 'A' }],
|
|
|
|
state: 'Done',
|
2020-10-01 05:58:06 -05:00
|
|
|
});
|
2018-04-30 15:00:56 -05:00
|
|
|
});
|
2018-03-12 09:13:05 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('results with table format should be transformed to table dataFrames', () => {
|
2021-10-15 06:37:27 -05:00
|
|
|
const request = ({
|
2021-09-17 06:39:26 -05:00
|
|
|
targets: [
|
2018-03-12 09:13:05 -05:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
format: 'table',
|
|
|
|
refId: 'A',
|
2018-03-12 09:13:05 -05:00
|
|
|
},
|
|
|
|
],
|
2021-09-17 06:39:26 -05:00
|
|
|
} as unknown) as DataQueryRequest<PromQuery>;
|
|
|
|
const response = ({
|
|
|
|
state: 'Done',
|
|
|
|
data: [
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [6, 5, 4],
|
|
|
|
labels: { label1: 'value1', label2: 'value2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
} as unknown) as DataQueryResponse;
|
2021-10-15 06:37:27 -05:00
|
|
|
const series = transformV2(response, request, {});
|
|
|
|
|
|
|
|
expect(series.data[0].fields[0].name).toEqual('Time');
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(series.data[0].fields[1].name).toEqual('label1');
|
|
|
|
expect(series.data[0].fields[2].name).toEqual('label2');
|
|
|
|
expect(series.data[0].fields[3].name).toEqual('Value');
|
|
|
|
expect(series.data[0].meta?.preferredVisualisationType).toEqual('table');
|
2020-08-18 07:47:25 -05:00
|
|
|
});
|
2018-03-12 09:37:21 -05:00
|
|
|
|
2021-10-15 06:37:27 -05:00
|
|
|
it('results with table format and multiple data frames should be transformed to 1 table dataFrame', () => {
|
|
|
|
const request = ({
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
format: 'table',
|
|
|
|
refId: 'A',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
} as unknown) as DataQueryRequest<PromQuery>;
|
|
|
|
const response = ({
|
|
|
|
state: 'Done',
|
|
|
|
data: [
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [6, 5, 4],
|
|
|
|
labels: { label1: 'value1', label2: 'value2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [2, 3, 7] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [2, 3, 7],
|
|
|
|
labels: { label3: 'value3', label4: 'value4' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
} as unknown) as DataQueryResponse;
|
|
|
|
const series = transformV2(response, request, {});
|
|
|
|
|
|
|
|
expect(series.data.length).toEqual(1);
|
|
|
|
expect(series.data[0].fields[0].name).toEqual('Time');
|
|
|
|
expect(series.data[0].fields[1].name).toEqual('label1');
|
|
|
|
expect(series.data[0].fields[2].name).toEqual('label2');
|
|
|
|
expect(series.data[0].fields[3].name).toEqual('label3');
|
|
|
|
expect(series.data[0].fields[4].name).toEqual('label4');
|
|
|
|
expect(series.data[0].fields[5].name).toEqual('Value #A');
|
|
|
|
expect(series.data[0].meta?.preferredVisualisationType).toEqual('table');
|
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('results with table and time_series format should be correctly transformed', () => {
|
|
|
|
const options = ({
|
|
|
|
targets: [
|
2020-05-08 00:59:35 -05:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
format: 'table',
|
|
|
|
refId: 'A',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'time_series',
|
|
|
|
refId: 'B',
|
2020-05-08 00:59:35 -05:00
|
|
|
},
|
|
|
|
],
|
2021-09-17 06:39:26 -05:00
|
|
|
} as unknown) as DataQueryRequest<PromQuery>;
|
|
|
|
const response = ({
|
|
|
|
state: 'Done',
|
|
|
|
data: [
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [6, 5, 4],
|
|
|
|
labels: { label1: 'value1', label2: 'value2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'B',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [6, 5, 4],
|
|
|
|
labels: { label1: 'value1', label2: 'value2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
} as unknown) as DataQueryResponse;
|
2021-10-12 06:16:09 -05:00
|
|
|
const series = transformV2(response, options, {});
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(series.data[0].fields.length).toEqual(2);
|
|
|
|
expect(series.data[0].meta?.preferredVisualisationType).toEqual('graph');
|
|
|
|
expect(series.data[1].fields.length).toEqual(4);
|
|
|
|
expect(series.data[1].meta?.preferredVisualisationType).toEqual('table');
|
2020-05-08 00:59:35 -05:00
|
|
|
});
|
2021-10-15 06:37:27 -05:00
|
|
|
|
|
|
|
it('results with heatmap format should be correctly transformed', () => {
|
|
|
|
const options = ({
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
format: 'heatmap',
|
|
|
|
refId: 'A',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
} as unknown) as DataQueryRequest<PromQuery>;
|
|
|
|
const response = ({
|
|
|
|
state: 'Done',
|
|
|
|
data: [
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'Time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'Value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [10, 10, 0],
|
|
|
|
labels: { le: '1' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'Time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'Value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [20, 10, 30],
|
|
|
|
labels: { le: '2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'Time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'Value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [30, 10, 40],
|
|
|
|
labels: { le: '3' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
} as unknown) as DataQueryResponse;
|
|
|
|
|
|
|
|
const series = transformV2(response, options, {});
|
|
|
|
expect(series.data[0].fields.length).toEqual(2);
|
|
|
|
expect(series.data[0].fields[1].values.toArray()).toEqual([10, 10, 0]);
|
|
|
|
expect(series.data[1].fields[1].values.toArray()).toEqual([10, 0, 30]);
|
|
|
|
expect(series.data[2].fields[1].values.toArray()).toEqual([10, 0, 10]);
|
|
|
|
});
|
2020-05-08 00:59:35 -05:00
|
|
|
});
|
2021-10-15 06:37:27 -05:00
|
|
|
describe('transformDFToTable', () => {
|
2021-09-17 06:39:26 -05:00
|
|
|
it('transforms dataFrame with response length 1 to table dataFrame', () => {
|
|
|
|
const df = new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [6, 5, 4],
|
|
|
|
labels: { label1: 'value1', label2: 'value2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2020-05-08 00:59:35 -05:00
|
|
|
|
2021-10-15 06:37:27 -05:00
|
|
|
const tableDf = transformDFToTable([df])[0];
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(tableDf.fields.length).toBe(4);
|
2021-10-15 06:37:27 -05:00
|
|
|
expect(tableDf.fields[0].name).toBe('Time');
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(tableDf.fields[1].name).toBe('label1');
|
|
|
|
expect(tableDf.fields[1].values.get(0)).toBe('value1');
|
|
|
|
expect(tableDf.fields[2].name).toBe('label2');
|
|
|
|
expect(tableDf.fields[2].values.get(0)).toBe('value2');
|
|
|
|
expect(tableDf.fields[3].name).toBe('Value');
|
2020-10-01 05:58:06 -05:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('transforms dataFrame with response length 2 to table dataFrame', () => {
|
|
|
|
const df = new MutableDataFrame({
|
|
|
|
refId: 'A',
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time, values: [6, 5, 4] },
|
|
|
|
{
|
|
|
|
name: 'value',
|
|
|
|
type: FieldType.number,
|
|
|
|
values: [6, 5, 4],
|
|
|
|
labels: { label1: 'value1', label2: 'value2' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2018-03-12 09:37:21 -05:00
|
|
|
|
2021-10-15 06:37:27 -05:00
|
|
|
const tableDf = transformDFToTable([df])[0];
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(tableDf.fields.length).toBe(4);
|
2021-10-15 06:37:27 -05:00
|
|
|
expect(tableDf.fields[0].name).toBe('Time');
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(tableDf.fields[1].name).toBe('label1');
|
|
|
|
expect(tableDf.fields[1].values.get(0)).toBe('value1');
|
|
|
|
expect(tableDf.fields[2].name).toBe('label2');
|
|
|
|
expect(tableDf.fields[2].values.get(0)).toBe('value2');
|
2021-10-15 06:37:27 -05:00
|
|
|
expect(tableDf.fields[3].name).toBe('Value');
|
2018-03-12 09:37:21 -05:00
|
|
|
});
|
2021-09-17 06:39:26 -05:00
|
|
|
});
|
2018-07-05 08:12:03 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('transform', () => {
|
|
|
|
const options: any = { target: {}, query: {} };
|
|
|
|
describe('When nothing is returned', () => {
|
|
|
|
it('should return empty array', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: '',
|
|
|
|
result: null,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const series = transform({ data: response } as any, options);
|
|
|
|
expect(series).toEqual([]);
|
|
|
|
});
|
|
|
|
it('should return empty array', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: '',
|
|
|
|
result: null,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const result = transform({ data: response } as any, { ...options, target: { format: 'table' } });
|
|
|
|
expect(result).toHaveLength(0);
|
|
|
|
});
|
2018-07-05 08:12:03 -05:00
|
|
|
});
|
2018-07-02 13:04:36 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('When resultFormat is table', () => {
|
2020-11-05 04:37:21 -06:00
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
2020-11-05 04:37:21 -06:00
|
|
|
values: [
|
2021-09-17 06:39:26 -05:00
|
|
|
[1443454528, '3846'],
|
|
|
|
[1443454530, '3848'],
|
2020-11-05 04:37:21 -06:00
|
|
|
],
|
|
|
|
},
|
2018-07-02 13:04:36 -05:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: {
|
|
|
|
__name__: 'test2',
|
|
|
|
instance: 'localhost:8080',
|
|
|
|
job: 'otherjob',
|
|
|
|
},
|
2019-11-19 07:59:39 -06:00
|
|
|
values: [
|
2021-09-17 06:39:26 -05:00
|
|
|
[1443454529, '3847'],
|
|
|
|
[1443454531, '3849'],
|
2019-11-19 07:59:39 -06:00
|
|
|
],
|
2018-07-02 13:04:36 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should return data frame', () => {
|
|
|
|
const result = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
target: {
|
|
|
|
responseListLength: 0,
|
|
|
|
refId: 'A',
|
|
|
|
format: 'table',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(result[0].fields[0].values.toArray()).toEqual([
|
|
|
|
1443454528000,
|
|
|
|
1443454530000,
|
|
|
|
1443454529000,
|
|
|
|
1443454531000,
|
|
|
|
]);
|
|
|
|
expect(result[0].fields[0].name).toBe('Time');
|
|
|
|
expect(result[0].fields[0].type).toBe(FieldType.time);
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual(['test', 'test', 'test2', 'test2']);
|
|
|
|
expect(result[0].fields[1].name).toBe('__name__');
|
|
|
|
expect(result[0].fields[1].config.filterable).toBe(true);
|
|
|
|
expect(result[0].fields[1].type).toBe(FieldType.string);
|
|
|
|
expect(result[0].fields[2].values.toArray()).toEqual(['', '', 'localhost:8080', 'localhost:8080']);
|
|
|
|
expect(result[0].fields[2].name).toBe('instance');
|
|
|
|
expect(result[0].fields[2].type).toBe(FieldType.string);
|
|
|
|
expect(result[0].fields[3].values.toArray()).toEqual(['testjob', 'testjob', 'otherjob', 'otherjob']);
|
|
|
|
expect(result[0].fields[3].name).toBe('job');
|
|
|
|
expect(result[0].fields[3].type).toBe(FieldType.string);
|
|
|
|
expect(result[0].fields[4].values.toArray()).toEqual([3846, 3848, 3847, 3849]);
|
|
|
|
expect(result[0].fields[4].name).toEqual('Value');
|
|
|
|
expect(result[0].fields[4].type).toBe(FieldType.number);
|
|
|
|
expect(result[0].refId).toBe('A');
|
2020-10-01 05:58:06 -05:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should include refId if response count is more than 2', () => {
|
|
|
|
const result = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
target: {
|
|
|
|
refId: 'B',
|
|
|
|
format: 'table',
|
|
|
|
},
|
|
|
|
responseListLength: 2,
|
|
|
|
});
|
2018-07-02 13:04:36 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(result[0].fields[4].name).toEqual('Value #B');
|
2020-10-01 05:58:06 -05:00
|
|
|
});
|
Field: getFieldTitle as field / series display identity and use it in all field name matchers & field / series name displays (#24024)
* common title handling
* show labels
* update comment
* Update changelog for v7.0.0-beta1 (#24007)
Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-Authored-By: Andrej Ocenas <mr.ocenas@gmail.com>
Co-Authored-By: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
* verify-repo-update: Fix Dockerfile.deb (#24030)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Upgrade build pipeline tool (#24021)
* CircleCI: Upgrade build pipeline tool
* Devenv: ignore enterprise (#24037)
* Add header icon to Add data source page (#24033)
* latest.json: Update testing version (#24038)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Fix login page redirected from password reset (#24032)
* Storybook: Rewrite stories to CSF (#23989)
* ColorPicker to CSF format
* Convert stories to CSF
* Do not export ClipboardButton
* Update ConfirmButton
* Remove unused imports
* Fix feedback
* changelog enterprise 7.0.0-beta1 (#24039)
* CircleCI: Bump grafana/build-container revision (#24043)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Changelog: Updates changelog with more feature details (#24040)
* Changelog: Updates changelog with more feature details
* spell fix
* spell fix
* Updates
* Readme update
* Updates
* Select: fixes so component loses focus on selecting value or pressing outside of input. (#24008)
* changed the value container to a class component to get it to work with focus (maybe something with context?).
* added e2e tests to verify that the select focus is working as it should.
* fixed according to feedback.
* updated snapshot.
* Devenv: add remote renderer to grafana (#24050)
* NewPanelEditor: minor UI twekas (#24042)
* Forward ref for tabs, use html props
* Inspect: add inspect label to drawer title
* Add tooltips to sidebar pane tabs, copy changes
* Remove unused import
* Place tooltips over tabs
* Inspector: dont show transformations select if there is only one data frame
* Review
* Changelog: Add a breaking change (#24051)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Unpin grafana/docs-base (#24054)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Search: close overlay on Esc press (#24003)
* Search: Close on Esc
* Search: Increase bottom padding for the last item in section
* Search: Move closing search to keybindingsSrv
* Search: Fix folder view
* Search: Do not move folders if already in folder
* Docs: Adds deprecation notice to changelog and docs for scripted dashboards (#24060)
* Update CHANGELOG.md (#24047)
Fix typo
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
* Documentation: Alternative Team Sync Wording (#23960)
* Alternative wording for team sync docs
Signed-off-by: Joe Elliott <number101010@gmail.com>
* Update docs/sources/auth/team-sync.md
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
* Fix misspell issues (#23905)
* Fix misspell issues
See,
$ golangci-lint run --timeout 10m --disable-all -E misspell ./...
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* Fix codespell issues
See,
$ codespell -S './.git*' -L 'uint,thru,pres,unknwon,serie,referer,uptodate,durationm'
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* ci please?
* non-empty commit - ci?
* Trigger build
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
* fix compile error
* better series display
* better display
* now with prometheus and loki
* a few more tests
* Improvements and tests
* thinking
* More advanced and smart default title generation
* Another fix
* Progress but dam this will be hard
* Reverting the time series Value field name change
* revert revert going in circles
* add a field state object
* Use state title when converting back to legacy format
* Improved the join (series to columsn) transformer
* Got tests running again
* Rewrite of seriesToColums that simplifies and fixing tests
* Fixed the tricky problem of multiple time field when not used in join
* Prometheus: Restoring prometheus formatting
* Graphite: Disable Grafana's series naming
* fixed imports
* Fixed tests and made rename transform change title instead
* Fixing more tests
* fix more tests
* fixed import issue
* Fixed more circular dependencies
* Renamed to getFieldTitle
* More rename
* Review feedback
* Fix for showing field title in calculate field transformer
* fieldOverride: Make it clear that state title after applying defaults & overrides
* Fixed ts issue
* Update packages/grafana-ui/src/components/TransformersUI/OrganizeFieldsTransformerEditor.tsx
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Richard Hartmann <RichiH@users.noreply.github.com>
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Mario Trangoni <mario@mariotrangoni.de>
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
2020-05-07 03:42:03 -05:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('When resultFormat is table and instant = true', () => {
|
2021-01-22 11:03:37 -06:00
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
2021-09-17 06:39:26 -05:00
|
|
|
resultType: 'vector',
|
Field: getFieldTitle as field / series display identity and use it in all field name matchers & field / series name displays (#24024)
* common title handling
* show labels
* update comment
* Update changelog for v7.0.0-beta1 (#24007)
Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-Authored-By: Andrej Ocenas <mr.ocenas@gmail.com>
Co-Authored-By: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
* verify-repo-update: Fix Dockerfile.deb (#24030)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Upgrade build pipeline tool (#24021)
* CircleCI: Upgrade build pipeline tool
* Devenv: ignore enterprise (#24037)
* Add header icon to Add data source page (#24033)
* latest.json: Update testing version (#24038)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Fix login page redirected from password reset (#24032)
* Storybook: Rewrite stories to CSF (#23989)
* ColorPicker to CSF format
* Convert stories to CSF
* Do not export ClipboardButton
* Update ConfirmButton
* Remove unused imports
* Fix feedback
* changelog enterprise 7.0.0-beta1 (#24039)
* CircleCI: Bump grafana/build-container revision (#24043)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Changelog: Updates changelog with more feature details (#24040)
* Changelog: Updates changelog with more feature details
* spell fix
* spell fix
* Updates
* Readme update
* Updates
* Select: fixes so component loses focus on selecting value or pressing outside of input. (#24008)
* changed the value container to a class component to get it to work with focus (maybe something with context?).
* added e2e tests to verify that the select focus is working as it should.
* fixed according to feedback.
* updated snapshot.
* Devenv: add remote renderer to grafana (#24050)
* NewPanelEditor: minor UI twekas (#24042)
* Forward ref for tabs, use html props
* Inspect: add inspect label to drawer title
* Add tooltips to sidebar pane tabs, copy changes
* Remove unused import
* Place tooltips over tabs
* Inspector: dont show transformations select if there is only one data frame
* Review
* Changelog: Add a breaking change (#24051)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Unpin grafana/docs-base (#24054)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Search: close overlay on Esc press (#24003)
* Search: Close on Esc
* Search: Increase bottom padding for the last item in section
* Search: Move closing search to keybindingsSrv
* Search: Fix folder view
* Search: Do not move folders if already in folder
* Docs: Adds deprecation notice to changelog and docs for scripted dashboards (#24060)
* Update CHANGELOG.md (#24047)
Fix typo
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
* Documentation: Alternative Team Sync Wording (#23960)
* Alternative wording for team sync docs
Signed-off-by: Joe Elliott <number101010@gmail.com>
* Update docs/sources/auth/team-sync.md
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
* Fix misspell issues (#23905)
* Fix misspell issues
See,
$ golangci-lint run --timeout 10m --disable-all -E misspell ./...
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* Fix codespell issues
See,
$ codespell -S './.git*' -L 'uint,thru,pres,unknwon,serie,referer,uptodate,durationm'
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* ci please?
* non-empty commit - ci?
* Trigger build
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
* fix compile error
* better series display
* better display
* now with prometheus and loki
* a few more tests
* Improvements and tests
* thinking
* More advanced and smart default title generation
* Another fix
* Progress but dam this will be hard
* Reverting the time series Value field name change
* revert revert going in circles
* add a field state object
* Use state title when converting back to legacy format
* Improved the join (series to columsn) transformer
* Got tests running again
* Rewrite of seriesToColums that simplifies and fixing tests
* Fixed the tricky problem of multiple time field when not used in join
* Prometheus: Restoring prometheus formatting
* Graphite: Disable Grafana's series naming
* fixed imports
* Fixed tests and made rename transform change title instead
* Fixing more tests
* fix more tests
* fixed import issue
* Fixed more circular dependencies
* Renamed to getFieldTitle
* More rename
* Review feedback
* Fix for showing field title in calculate field transformer
* fieldOverride: Make it clear that state title after applying defaults & overrides
* Fixed ts issue
* Update packages/grafana-ui/src/components/TransformersUI/OrganizeFieldsTransformerEditor.tsx
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Richard Hartmann <RichiH@users.noreply.github.com>
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Mario Trangoni <mario@mariotrangoni.de>
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
2020-05-07 03:42:03 -05:00
|
|
|
result: [
|
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
|
|
|
value: [1443454528, '3846'],
|
Field: getFieldTitle as field / series display identity and use it in all field name matchers & field / series name displays (#24024)
* common title handling
* show labels
* update comment
* Update changelog for v7.0.0-beta1 (#24007)
Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-Authored-By: Andrej Ocenas <mr.ocenas@gmail.com>
Co-Authored-By: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
* verify-repo-update: Fix Dockerfile.deb (#24030)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Upgrade build pipeline tool (#24021)
* CircleCI: Upgrade build pipeline tool
* Devenv: ignore enterprise (#24037)
* Add header icon to Add data source page (#24033)
* latest.json: Update testing version (#24038)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Fix login page redirected from password reset (#24032)
* Storybook: Rewrite stories to CSF (#23989)
* ColorPicker to CSF format
* Convert stories to CSF
* Do not export ClipboardButton
* Update ConfirmButton
* Remove unused imports
* Fix feedback
* changelog enterprise 7.0.0-beta1 (#24039)
* CircleCI: Bump grafana/build-container revision (#24043)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Changelog: Updates changelog with more feature details (#24040)
* Changelog: Updates changelog with more feature details
* spell fix
* spell fix
* Updates
* Readme update
* Updates
* Select: fixes so component loses focus on selecting value or pressing outside of input. (#24008)
* changed the value container to a class component to get it to work with focus (maybe something with context?).
* added e2e tests to verify that the select focus is working as it should.
* fixed according to feedback.
* updated snapshot.
* Devenv: add remote renderer to grafana (#24050)
* NewPanelEditor: minor UI twekas (#24042)
* Forward ref for tabs, use html props
* Inspect: add inspect label to drawer title
* Add tooltips to sidebar pane tabs, copy changes
* Remove unused import
* Place tooltips over tabs
* Inspector: dont show transformations select if there is only one data frame
* Review
* Changelog: Add a breaking change (#24051)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Unpin grafana/docs-base (#24054)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Search: close overlay on Esc press (#24003)
* Search: Close on Esc
* Search: Increase bottom padding for the last item in section
* Search: Move closing search to keybindingsSrv
* Search: Fix folder view
* Search: Do not move folders if already in folder
* Docs: Adds deprecation notice to changelog and docs for scripted dashboards (#24060)
* Update CHANGELOG.md (#24047)
Fix typo
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
* Documentation: Alternative Team Sync Wording (#23960)
* Alternative wording for team sync docs
Signed-off-by: Joe Elliott <number101010@gmail.com>
* Update docs/sources/auth/team-sync.md
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
* Fix misspell issues (#23905)
* Fix misspell issues
See,
$ golangci-lint run --timeout 10m --disable-all -E misspell ./...
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* Fix codespell issues
See,
$ codespell -S './.git*' -L 'uint,thru,pres,unknwon,serie,referer,uptodate,durationm'
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* ci please?
* non-empty commit - ci?
* Trigger build
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
* fix compile error
* better series display
* better display
* now with prometheus and loki
* a few more tests
* Improvements and tests
* thinking
* More advanced and smart default title generation
* Another fix
* Progress but dam this will be hard
* Reverting the time series Value field name change
* revert revert going in circles
* add a field state object
* Use state title when converting back to legacy format
* Improved the join (series to columsn) transformer
* Got tests running again
* Rewrite of seriesToColums that simplifies and fixing tests
* Fixed the tricky problem of multiple time field when not used in join
* Prometheus: Restoring prometheus formatting
* Graphite: Disable Grafana's series naming
* fixed imports
* Fixed tests and made rename transform change title instead
* Fixing more tests
* fix more tests
* fixed import issue
* Fixed more circular dependencies
* Renamed to getFieldTitle
* More rename
* Review feedback
* Fix for showing field title in calculate field transformer
* fieldOverride: Make it clear that state title after applying defaults & overrides
* Fixed ts issue
* Update packages/grafana-ui/src/components/TransformersUI/OrganizeFieldsTransformerEditor.tsx
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Richard Hartmann <RichiH@users.noreply.github.com>
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Mario Trangoni <mario@mariotrangoni.de>
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
2020-05-07 03:42:03 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should return data frame', () => {
|
|
|
|
const result = transform({ data: response } as any, { ...options, target: { format: 'table' } });
|
|
|
|
expect(result[0].fields[0].values.toArray()).toEqual([1443454528000]);
|
|
|
|
expect(result[0].fields[0].name).toBe('Time');
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual(['test']);
|
|
|
|
expect(result[0].fields[1].name).toBe('__name__');
|
|
|
|
expect(result[0].fields[2].values.toArray()).toEqual(['testjob']);
|
|
|
|
expect(result[0].fields[2].name).toBe('job');
|
|
|
|
expect(result[0].fields[3].values.toArray()).toEqual([3846]);
|
|
|
|
expect(result[0].fields[3].name).toEqual('Value');
|
2020-10-01 05:58:06 -05:00
|
|
|
});
|
Field: getFieldTitle as field / series display identity and use it in all field name matchers & field / series name displays (#24024)
* common title handling
* show labels
* update comment
* Update changelog for v7.0.0-beta1 (#24007)
Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-Authored-By: Andrej Ocenas <mr.ocenas@gmail.com>
Co-Authored-By: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
* verify-repo-update: Fix Dockerfile.deb (#24030)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Upgrade build pipeline tool (#24021)
* CircleCI: Upgrade build pipeline tool
* Devenv: ignore enterprise (#24037)
* Add header icon to Add data source page (#24033)
* latest.json: Update testing version (#24038)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Fix login page redirected from password reset (#24032)
* Storybook: Rewrite stories to CSF (#23989)
* ColorPicker to CSF format
* Convert stories to CSF
* Do not export ClipboardButton
* Update ConfirmButton
* Remove unused imports
* Fix feedback
* changelog enterprise 7.0.0-beta1 (#24039)
* CircleCI: Bump grafana/build-container revision (#24043)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Changelog: Updates changelog with more feature details (#24040)
* Changelog: Updates changelog with more feature details
* spell fix
* spell fix
* Updates
* Readme update
* Updates
* Select: fixes so component loses focus on selecting value or pressing outside of input. (#24008)
* changed the value container to a class component to get it to work with focus (maybe something with context?).
* added e2e tests to verify that the select focus is working as it should.
* fixed according to feedback.
* updated snapshot.
* Devenv: add remote renderer to grafana (#24050)
* NewPanelEditor: minor UI twekas (#24042)
* Forward ref for tabs, use html props
* Inspect: add inspect label to drawer title
* Add tooltips to sidebar pane tabs, copy changes
* Remove unused import
* Place tooltips over tabs
* Inspector: dont show transformations select if there is only one data frame
* Review
* Changelog: Add a breaking change (#24051)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* CircleCI: Unpin grafana/docs-base (#24054)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
* Search: close overlay on Esc press (#24003)
* Search: Close on Esc
* Search: Increase bottom padding for the last item in section
* Search: Move closing search to keybindingsSrv
* Search: Fix folder view
* Search: Do not move folders if already in folder
* Docs: Adds deprecation notice to changelog and docs for scripted dashboards (#24060)
* Update CHANGELOG.md (#24047)
Fix typo
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
* Documentation: Alternative Team Sync Wording (#23960)
* Alternative wording for team sync docs
Signed-off-by: Joe Elliott <number101010@gmail.com>
* Update docs/sources/auth/team-sync.md
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
* Fix misspell issues (#23905)
* Fix misspell issues
See,
$ golangci-lint run --timeout 10m --disable-all -E misspell ./...
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* Fix codespell issues
See,
$ codespell -S './.git*' -L 'uint,thru,pres,unknwon,serie,referer,uptodate,durationm'
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
* ci please?
* non-empty commit - ci?
* Trigger build
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
* fix compile error
* better series display
* better display
* now with prometheus and loki
* a few more tests
* Improvements and tests
* thinking
* More advanced and smart default title generation
* Another fix
* Progress but dam this will be hard
* Reverting the time series Value field name change
* revert revert going in circles
* add a field state object
* Use state title when converting back to legacy format
* Improved the join (series to columsn) transformer
* Got tests running again
* Rewrite of seriesToColums that simplifies and fixing tests
* Fixed the tricky problem of multiple time field when not used in join
* Prometheus: Restoring prometheus formatting
* Graphite: Disable Grafana's series naming
* fixed imports
* Fixed tests and made rename transform change title instead
* Fixing more tests
* fix more tests
* fixed import issue
* Fixed more circular dependencies
* Renamed to getFieldTitle
* More rename
* Review feedback
* Fix for showing field title in calculate field transformer
* fieldOverride: Make it clear that state title after applying defaults & overrides
* Fixed ts issue
* Update packages/grafana-ui/src/components/TransformersUI/OrganizeFieldsTransformerEditor.tsx
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Richard Hartmann <RichiH@users.noreply.github.com>
Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
Co-authored-by: Joe Elliott <joe.elliott@grafana.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Mario Trangoni <mario@mariotrangoni.de>
Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
2020-05-07 03:42:03 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should return le label values parsed as numbers', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'vector',
|
|
|
|
result: [
|
|
|
|
{
|
|
|
|
metric: { le: '102' },
|
|
|
|
value: [1594908838, '0'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const result = transform({ data: response } as any, { ...options, target: { format: 'table' } });
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([102]);
|
|
|
|
expect(result[0].fields[1].type).toEqual(FieldType.number);
|
|
|
|
});
|
2020-12-01 03:36:38 -06:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('When instant = true', () => {
|
2018-07-02 13:04:36 -05:00
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
2021-09-17 06:39:26 -05:00
|
|
|
resultType: 'vector',
|
2018-07-02 13:04:36 -05:00
|
|
|
result: [
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
2021-09-17 06:39:26 -05:00
|
|
|
value: [1443454528, '3846'],
|
2018-07-02 13:04:36 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should return data frame', () => {
|
|
|
|
const result: DataFrame[] = transform({ data: response } as any, { ...options, query: { instant: true } });
|
|
|
|
expect(result[0].name).toBe('test{job="testjob"}');
|
|
|
|
});
|
2018-07-02 13:04:36 -05:00
|
|
|
});
|
2020-10-21 03:21:39 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('When resultFormat is heatmap', () => {
|
|
|
|
const getResponse = (result: any) => ({
|
2020-10-21 03:21:39 -05:00
|
|
|
status: 'success',
|
|
|
|
data: {
|
2021-09-17 06:39:26 -05:00
|
|
|
resultType: 'matrix',
|
|
|
|
result,
|
2020-10-21 03:21:39 -05:00
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
format: 'heatmap',
|
|
|
|
start: 1445000010,
|
|
|
|
end: 1445000030,
|
|
|
|
legendFormat: '{{le}}',
|
2020-10-21 03:21:39 -05:00
|
|
|
};
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should convert cumulative histogram to regular', () => {
|
|
|
|
const response = getResponse([
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', le: '1' },
|
|
|
|
values: [
|
|
|
|
[1445000010, '10'],
|
|
|
|
[1445000020, '10'],
|
|
|
|
[1445000030, '0'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', le: '2' },
|
|
|
|
values: [
|
|
|
|
[1445000010, '20'],
|
|
|
|
[1445000020, '10'],
|
|
|
|
[1445000030, '30'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', le: '3' },
|
|
|
|
values: [
|
|
|
|
[1445000010, '30'],
|
|
|
|
[1445000020, '10'],
|
|
|
|
[1445000030, '40'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
const result = transform({ data: response } as any, { query: options, target: options } as any);
|
|
|
|
expect(result[0].fields[0].values.toArray()).toEqual([1445000010000, 1445000020000, 1445000030000]);
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([10, 10, 0]);
|
|
|
|
expect(result[1].fields[0].values.toArray()).toEqual([1445000010000, 1445000020000, 1445000030000]);
|
|
|
|
expect(result[1].fields[1].values.toArray()).toEqual([10, 0, 30]);
|
|
|
|
expect(result[2].fields[0].values.toArray()).toEqual([1445000010000, 1445000020000, 1445000030000]);
|
|
|
|
expect(result[2].fields[1].values.toArray()).toEqual([10, 0, 10]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle missing datapoints', () => {
|
|
|
|
const response = getResponse([
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', le: '1' },
|
|
|
|
values: [
|
|
|
|
[1445000010, '1'],
|
|
|
|
[1445000020, '2'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', le: '2' },
|
|
|
|
values: [
|
|
|
|
[1445000010, '2'],
|
|
|
|
[1445000020, '5'],
|
|
|
|
[1445000030, '1'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', le: '3' },
|
|
|
|
values: [
|
|
|
|
[1445000010, '3'],
|
|
|
|
[1445000020, '7'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
const result = transform({ data: response } as any, { query: options, target: options } as any);
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([1, 2]);
|
|
|
|
expect(result[1].fields[1].values.toArray()).toEqual([1, 3, 1]);
|
|
|
|
expect(result[2].fields[1].values.toArray()).toEqual([1, 2]);
|
2020-10-21 03:21:39 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('When the response is a matrix', () => {
|
|
|
|
it('should have labels with the value field', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob', instance: 'testinstance' },
|
|
|
|
values: [
|
|
|
|
[0, '10'],
|
|
|
|
[1, '10'],
|
|
|
|
[2, '0'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
2020-10-21 03:21:39 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
const result: DataFrame[] = transform({ data: response } as any, {
|
|
|
|
...options,
|
2020-10-21 03:21:39 -05:00
|
|
|
});
|
2021-09-17 06:39:26 -05:00
|
|
|
|
|
|
|
expect(result[0].fields[1].labels).toBeDefined();
|
|
|
|
expect(result[0].fields[1].labels?.instance).toBe('testinstance');
|
|
|
|
expect(result[0].fields[1].labels?.job).toBe('testjob');
|
2020-10-21 03:21:39 -05:00
|
|
|
});
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should transform into a data frame', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
|
|
|
{
|
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
|
|
|
values: [
|
|
|
|
[0, '10'],
|
|
|
|
[1, '10'],
|
|
|
|
[2, '0'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2021-01-15 09:20:20 -06:00
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
};
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
const result: DataFrame[] = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
query: {
|
|
|
|
start: 0,
|
|
|
|
end: 2,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(result[0].fields[0].values.toArray()).toEqual([0, 1000, 2000]);
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([10, 10, 0]);
|
|
|
|
expect(result[0].name).toBe('test{job="testjob"}');
|
|
|
|
});
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should fill null values', () => {
|
|
|
|
const result = transform({ data: matrixResponse } as any, {
|
|
|
|
...options,
|
|
|
|
query: { step: 1, start: 0, end: 2 },
|
|
|
|
});
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(result[0].fields[0].values.toArray()).toEqual([0, 1000, 2000]);
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([null, 10, 0]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use __name__ label as series name', () => {
|
|
|
|
const result = transform({ data: matrixResponse } as any, {
|
|
|
|
...options,
|
|
|
|
query: {
|
|
|
|
step: 1,
|
|
|
|
start: 0,
|
|
|
|
end: 2,
|
2021-03-30 12:34:08 -05:00
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
});
|
|
|
|
expect(result[0].name).toEqual('test{job="testjob"}');
|
|
|
|
});
|
2021-03-30 12:34:08 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should use query as series name when __name__ is not available and metric is empty', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
|
|
|
{
|
|
|
|
metric: {},
|
|
|
|
values: [[0, '10']],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const expr = 'histogram_quantile(0.95, sum(rate(tns_request_duration_seconds_bucket[5m])) by (le))';
|
|
|
|
const result = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
query: {
|
|
|
|
step: 1,
|
|
|
|
start: 0,
|
|
|
|
end: 2,
|
|
|
|
expr,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(result[0].name).toEqual(expr);
|
|
|
|
});
|
2021-03-30 12:34:08 -05:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should set frame name to undefined if no __name__ label but there are other labels', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
2021-01-15 09:20:20 -06:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: { job: 'testjob' },
|
|
|
|
values: [
|
|
|
|
[1, '10'],
|
|
|
|
[2, '0'],
|
|
|
|
],
|
2021-01-15 09:20:20 -06:00
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const result = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
query: {
|
|
|
|
step: 1,
|
|
|
|
start: 0,
|
|
|
|
end: 2,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(result[0].name).toBe('{job="testjob"}');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not set displayName for ValueFields', () => {
|
|
|
|
const result = transform({ data: matrixResponse } as any, options);
|
|
|
|
expect(result[0].fields[1].config.displayName).toBeUndefined();
|
|
|
|
expect(result[0].fields[1].config.displayNameFromDS).toBe('test{job="testjob"}');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should align null values with step', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [
|
2021-01-15 09:20:20 -06:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
|
|
|
values: [
|
|
|
|
[4, '10'],
|
|
|
|
[8, '10'],
|
|
|
|
],
|
2021-01-15 09:20:20 -06:00
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const result = transform({ data: response } as any, { ...options, query: { step: 2, start: 0, end: 8 } });
|
|
|
|
expect(result[0].fields[0].values.toArray()).toEqual([0, 2000, 4000, 6000, 8000]);
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([null, null, 10, null, 10]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('When infinity values are returned', () => {
|
|
|
|
describe('When resultType is scalar', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'scalar',
|
|
|
|
result: [1443454528, '+Inf'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
it('should correctly parse values', () => {
|
|
|
|
const result: DataFrame[] = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
target: { format: 'table' },
|
|
|
|
});
|
|
|
|
expect(result[0].fields[1].values.toArray()).toEqual([Number.POSITIVE_INFINITY]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('When resultType is vector', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
resultType: 'vector',
|
|
|
|
result: [
|
2021-01-15 09:20:20 -06:00
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
|
|
|
value: [1443454528, '+Inf'],
|
2021-01-15 09:20:20 -06:00
|
|
|
},
|
|
|
|
{
|
2021-09-17 06:39:26 -05:00
|
|
|
metric: { __name__: 'test', job: 'testjob' },
|
|
|
|
value: [1443454528, '-Inf'],
|
2021-01-15 09:20:20 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-09-17 06:39:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('When format is table', () => {
|
|
|
|
it('should correctly parse values', () => {
|
|
|
|
const result: DataFrame[] = transform({ data: response } as any, {
|
|
|
|
...options,
|
|
|
|
target: { format: 'table' },
|
|
|
|
});
|
|
|
|
expect(result[0].fields[3].values.toArray()).toEqual([Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-01-15 09:20:20 -06:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
const exemplarsResponse = {
|
|
|
|
status: 'success',
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
seriesLabels: { __name__: 'test' },
|
|
|
|
exemplars: [
|
|
|
|
{
|
|
|
|
timestamp: 1610449069.957,
|
|
|
|
labels: { traceID: '5020b5bc45117f07' },
|
|
|
|
value: 0.002074123,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
describe('When the response is exemplar data', () => {
|
|
|
|
it('should return as an data frame with a dataTopic annotations', () => {
|
|
|
|
const result = transform({ data: exemplarsResponse } as any, options);
|
|
|
|
|
|
|
|
expect(result[0].meta?.dataTopic).toBe('annotations');
|
|
|
|
expect(result[0].fields.length).toBe(4); // __name__, traceID, Time, Value
|
|
|
|
expect(result[0].length).toBe(1);
|
2021-01-15 09:20:20 -06:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should return with an empty array when data is empty', () => {
|
|
|
|
const result = transform(
|
|
|
|
{
|
|
|
|
data: {
|
|
|
|
status: 'success',
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
} as any,
|
|
|
|
options
|
|
|
|
);
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(result).toHaveLength(0);
|
2021-01-15 09:20:20 -06:00
|
|
|
});
|
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
it('should remove exemplars that are too close to each other', () => {
|
|
|
|
const response = {
|
|
|
|
status: 'success',
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
exemplars: [
|
|
|
|
{
|
|
|
|
timestamp: 1610449070.0,
|
|
|
|
value: 5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
timestamp: 1610449070.0,
|
|
|
|
value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
timestamp: 1610449070.5,
|
|
|
|
value: 13,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
timestamp: 1610449070.3,
|
|
|
|
value: 20,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* the standard deviation for the above values is 8.4 this means that we show the highest
|
|
|
|
* value (20) and then the next value should be 2 times the standard deviation which is 1
|
|
|
|
**/
|
|
|
|
const result = transform({ data: response } as any, options);
|
|
|
|
expect(result[0].length).toBe(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('data link', () => {
|
|
|
|
it('should be added to the field if found with url', () => {
|
|
|
|
const result = transform({ data: exemplarsResponse } as any, {
|
|
|
|
...options,
|
|
|
|
exemplarTraceIdDestinations: [{ name: 'traceID', url: 'http://localhost' }],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(result[0].fields.some((f) => f.config.links?.length)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be added to the field if found with internal link', () => {
|
|
|
|
const result = transform({ data: exemplarsResponse } as any, {
|
|
|
|
...options,
|
|
|
|
exemplarTraceIdDestinations: [{ name: 'traceID', datasourceUid: 'jaeger' }],
|
|
|
|
});
|
2021-01-15 09:20:20 -06:00
|
|
|
|
2021-09-17 06:39:26 -05:00
|
|
|
expect(result[0].fields.some((f) => f.config.links?.length)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not add link if exemplarTraceIdDestinations is not configured', () => {
|
|
|
|
const result = transform({ data: exemplarsResponse } as any, options);
|
|
|
|
|
|
|
|
expect(result[0].fields.some((f) => f.config.links?.length)).toBe(false);
|
|
|
|
});
|
2021-01-15 09:20:20 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-03-12 09:13:05 -05:00
|
|
|
});
|