mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Fix for prometheus legend formats for instant time series queries (#24407)
* Prometheus: Fix for prometheus legend formats for instance time series queries * correct old test
This commit is contained in:
parent
648dda96e9
commit
243fa5ea63
@ -736,7 +736,7 @@ describe('PrometheusDatasource', () => {
|
||||
const frame = toDataFrame(results.data[0]);
|
||||
expect(results.data.length).toBe(1);
|
||||
expect(frame.name).toBe('test{job="testjob"}');
|
||||
expect(getFieldTitle(frame.fields[1])).toBe('Value');
|
||||
expect(getFieldTitle(frame.fields[1])).toBe('test{job="testjob"}');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -116,6 +116,27 @@ describe('Prometheus Result Transformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('When resultFormat is time series and instant = true', () => {
|
||||
const response = {
|
||||
status: 'success',
|
||||
data: {
|
||||
resultType: 'vector',
|
||||
result: [
|
||||
{
|
||||
metric: { __name__: 'test', job: 'testjob' },
|
||||
value: [1443454528, '3846'],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
it('should return time series', () => {
|
||||
const timeSeries = ctx.resultTransformer.transform({ data: response }, {});
|
||||
expect(timeSeries[0].target).toBe('test{job="testjob"}');
|
||||
expect(timeSeries[0].title).toBe('test{job="testjob"}');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When resultFormat is heatmap', () => {
|
||||
const response = {
|
||||
status: 'success',
|
||||
|
@ -143,7 +143,7 @@ export class ResultTransformer {
|
||||
const dps = [];
|
||||
const { name, labels } = this.createLabelInfo(md.metric, options);
|
||||
dps.push([parseFloat(md.value[1]), md.value[0] * 1000]);
|
||||
return { target: name, datapoints: dps, tags: labels, refId: options.refId, meta: options.meta };
|
||||
return { target: name, title: name, datapoints: dps, tags: labels, refId: options.refId, meta: options.meta };
|
||||
}
|
||||
|
||||
createLabelInfo(labels: { [key: string]: string }, options: any): { name?: string; labels: Labels; title?: string } {
|
||||
|
Loading…
Reference in New Issue
Block a user