CloudWatch: re-add filter to handleMetricQueries (#47341)

pull/46535/head^2
Isabella Siu 3 years ago committed by GitHub
parent 3a7fc80948
commit 05b1edb4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      public/app/plugins/datasource/cloudwatch/datasource.ts

@ -259,25 +259,27 @@ export class CloudWatchDatasource
metricQueries: CloudWatchMetricsQuery[],
options: DataQueryRequest<CloudWatchQuery>
): Observable<DataQueryResponse> => {
const validMetricsQueries = metricQueries.map((item: CloudWatchMetricsQuery): MetricQuery => {
item.region = this.templateSrv.replace(this.getActualRegion(item.region), options.scopedVars);
item.namespace = this.replace(item.namespace, options.scopedVars, true, 'namespace');
item.metricName = this.replace(item.metricName, options.scopedVars, true, 'metric name');
item.dimensions = this.convertDimensionFormat(item.dimensions ?? {}, options.scopedVars);
item.statistic = this.templateSrv.replace(item.statistic, options.scopedVars);
item.period = String(this.getPeriod(item, options)); // use string format for period in graph query, and alerting
item.id = this.templateSrv.replace(item.id, options.scopedVars);
item.expression = this.templateSrv.replace(item.expression, options.scopedVars);
item.sqlExpression = this.templateSrv.replace(item.sqlExpression, options.scopedVars, 'raw');
return {
intervalMs: options.intervalMs,
maxDataPoints: options.maxDataPoints,
...item,
type: 'timeSeriesQuery',
datasource: this.getRef(),
};
});
const validMetricsQueries = metricQueries
.filter(this.filterQuery)
.map((item: CloudWatchMetricsQuery): MetricQuery => {
item.region = this.templateSrv.replace(this.getActualRegion(item.region), options.scopedVars);
item.namespace = this.replace(item.namespace, options.scopedVars, true, 'namespace');
item.metricName = this.replace(item.metricName, options.scopedVars, true, 'metric name');
item.dimensions = this.convertDimensionFormat(item.dimensions ?? {}, options.scopedVars);
item.statistic = this.templateSrv.replace(item.statistic, options.scopedVars);
item.period = String(this.getPeriod(item, options)); // use string format for period in graph query, and alerting
item.id = this.templateSrv.replace(item.id, options.scopedVars);
item.expression = this.templateSrv.replace(item.expression, options.scopedVars);
item.sqlExpression = this.templateSrv.replace(item.sqlExpression, options.scopedVars, 'raw');
return {
intervalMs: options.intervalMs,
maxDataPoints: options.maxDataPoints,
...item,
type: 'timeSeriesQuery',
datasource: this.getRef(),
};
});
// No valid targets, return the empty result to save a round trip.
if (isEmpty(validMetricsQueries)) {

Loading…
Cancel
Save