Cloudwatch: Add monitoring badge for metric insights (#89956)

This commit is contained in:
Ida Štambuk
2024-07-04 11:22:52 +02:00
committed by GitHub
parent 844d575681
commit 4fc42b8a71
2 changed files with 6 additions and 2 deletions

View File

@@ -347,7 +347,7 @@ describe('QueryEditor should render right editor', () => {
config.featureToggles.cloudwatchMetricInsightsCrossAccount = true; config.featureToggles.cloudwatchMetricInsightsCrossAccount = true;
props.datasource.resources.getAccounts = jest.fn().mockResolvedValue(['account123']); props.datasource.resources.getAccounts = jest.fn().mockResolvedValue(['account123']);
render(<QueryEditor {...props} query={validMetricQueryBuilderQuery} />); render(<QueryEditor {...props} query={validMetricQueryBuilderQuery} />);
await screen.findByText('Metric Query'); await screen.findByText('Metric Insights');
expect(await screen.findByText('Account')).toBeInTheDocument(); expect(await screen.findByText('Account')).toBeInTheDocument();
}); });
}); });

View File

@@ -58,12 +58,16 @@ const QueryHeader = ({
onChange({ ...query, region }); onChange({ ...query, region });
} }
}; };
const metricInsightsCrossAccountEnabled = config.featureToggles.cloudwatchMetricInsightsCrossAccount;
const shouldDisplayMonitoringBadge = const shouldDisplayMonitoringBadge =
config.featureToggles.cloudWatchCrossAccountQuerying && config.featureToggles.cloudWatchCrossAccountQuerying &&
isMonitoringAccount && isMonitoringAccount &&
(query.queryMode === 'Logs' || (query.queryMode === 'Logs' ||
(isCloudWatchMetricsQuery(query) && query.metricQueryType === MetricQueryType.Search)); (isCloudWatchMetricsQuery(query) && query.metricQueryType === MetricQueryType.Search) ||
(metricInsightsCrossAccountEnabled &&
isCloudWatchMetricsQuery(query) &&
query.metricQueryType === MetricQueryType.Insights));
return ( return (
<> <>