mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
CloudWatch: List all metrics properly in SQL autocomplete (#45898)
* make sure right value is passed for metric * add unit test
This commit is contained in:
parent
647c5208d7
commit
8e08128f83
@ -249,6 +249,26 @@ describe('datasource', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('resource requests', () => {
|
||||
it('should map resource response to metric response', async () => {
|
||||
const datasource = setupMockedDataSource().datasource;
|
||||
datasource.doMetricResourceRequest = jest.fn().mockResolvedValue([
|
||||
{
|
||||
text: 'AWS/EC2',
|
||||
value: 'CPUUtilization',
|
||||
},
|
||||
{
|
||||
text: 'AWS/Redshift',
|
||||
value: 'CPUPercentage',
|
||||
},
|
||||
]);
|
||||
const allMetrics = await datasource.getAllMetrics('us-east-2');
|
||||
expect(allMetrics[0].metricName).toEqual('CPUUtilization');
|
||||
expect(allMetrics[0].namespace).toEqual('AWS/EC2');
|
||||
expect(allMetrics[1].metricName).toEqual('CPUPercentage');
|
||||
expect(allMetrics[1].namespace).toEqual('AWS/Redshift');
|
||||
});
|
||||
});
|
||||
|
||||
describe('performTimeSeriesQuery', () => {
|
||||
it('should return the same length of data as result', async () => {
|
||||
|
@ -670,7 +670,7 @@ export class CloudWatchDatasource
|
||||
region: this.templateSrv.replace(this.getActualRegion(region)),
|
||||
});
|
||||
|
||||
return values.map((v) => ({ metricName: v.label, namespace: v.text }));
|
||||
return values.map((v) => ({ metricName: v.value, namespace: v.text }));
|
||||
}
|
||||
|
||||
async getDimensionKeys(
|
||||
|
Loading…
Reference in New Issue
Block a user