Commit eccc6adf by Ryan McKinley Committed by Torkel Ödegaard

TimeSeries: datasources with labels should export tags (not labels) (#18977)

* merge master

* export prometheus tags
parent 14a74057
...@@ -76,7 +76,7 @@ export class ResultTransformer { ...@@ -76,7 +76,7 @@ export class ResultTransformer {
datapoints: dps, datapoints: dps,
query: options.query, query: options.query,
target: metricLabel, target: metricLabel,
labels: metricData.metric, tags: metricData.metric,
}; };
} }
......
...@@ -151,19 +151,19 @@ describe('Prometheus Result Transformer', () => { ...@@ -151,19 +151,19 @@ describe('Prometheus Result Transformer', () => {
target: '1', target: '1',
query: undefined, query: undefined,
datapoints: [[10, 1445000010000], [10, 1445000020000], [0, 1445000030000]], datapoints: [[10, 1445000010000], [10, 1445000020000], [0, 1445000030000]],
labels: { __name__: 'test', job: 'testjob', le: '1' }, tags: { __name__: 'test', job: 'testjob', le: '1' },
}, },
{ {
target: '2', target: '2',
query: undefined, query: undefined,
datapoints: [[10, 1445000010000], [0, 1445000020000], [30, 1445000030000]], datapoints: [[10, 1445000010000], [0, 1445000020000], [30, 1445000030000]],
labels: { __name__: 'test', job: 'testjob', le: '2' }, tags: { __name__: 'test', job: 'testjob', le: '2' },
}, },
{ {
target: '3', target: '3',
query: undefined, query: undefined,
datapoints: [[10, 1445000010000], [0, 1445000020000], [10, 1445000030000]], datapoints: [[10, 1445000010000], [0, 1445000020000], [10, 1445000030000]],
labels: { __name__: 'test', job: 'testjob', le: '3' }, tags: { __name__: 'test', job: 'testjob', le: '3' },
}, },
]); ]);
}); });
...@@ -225,7 +225,7 @@ describe('Prometheus Result Transformer', () => { ...@@ -225,7 +225,7 @@ describe('Prometheus Result Transformer', () => {
target: 'test{job="testjob"}', target: 'test{job="testjob"}',
query: undefined, query: undefined,
datapoints: [[10, 0], [10, 1000], [0, 2000]], datapoints: [[10, 0], [10, 1000], [0, 2000]],
labels: { job: 'testjob' }, tags: { job: 'testjob' },
}, },
]); ]);
}); });
...@@ -256,7 +256,7 @@ describe('Prometheus Result Transformer', () => { ...@@ -256,7 +256,7 @@ describe('Prometheus Result Transformer', () => {
target: 'test{job="testjob"}', target: 'test{job="testjob"}',
query: undefined, query: undefined,
datapoints: [[null, 0], [10, 1000], [0, 2000]], datapoints: [[null, 0], [10, 1000], [0, 2000]],
labels: { job: 'testjob' }, tags: { job: 'testjob' },
}, },
]); ]);
}); });
...@@ -287,7 +287,7 @@ describe('Prometheus Result Transformer', () => { ...@@ -287,7 +287,7 @@ describe('Prometheus Result Transformer', () => {
target: 'test{job="testjob"}', target: 'test{job="testjob"}',
query: undefined, query: undefined,
datapoints: [[null, 0], [null, 2000], [10, 4000], [null, 6000], [10, 8000]], datapoints: [[null, 0], [null, 2000], [10, 4000], [null, 6000], [10, 8000]],
labels: { job: 'testjob' }, tags: { job: 'testjob' },
}, },
]); ]);
}); });
......
...@@ -81,7 +81,12 @@ export class TestDataDataSource extends DataSourceApi<TestDataQuery> { ...@@ -81,7 +81,12 @@ export class TestDataDataSource extends DataSourceApi<TestDataQuery> {
} }
for (const series of results.series || []) { for (const series of results.series || []) {
data.push({ target: series.name, datapoints: series.points, refId: query.refId }); data.push({
target: series.name,
datapoints: series.points,
refId: query.refId,
tags: series.tags,
});
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment