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

This commit is contained in:
Isabella Siu 2022-04-06 03:02:34 -04:00 committed by GitHub
parent 3a7fc80948
commit 05b1edb4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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