From 4fc42b8a710dccd8d05654ab85481525678f5729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ida=20=C5=A0tambuk?= Date: Thu, 4 Jul 2024 11:22:52 +0200 Subject: [PATCH] Cloudwatch: Add monitoring badge for metric insights (#89956) --- .../cloudwatch/components/QueryEditor/QueryEditor.test.tsx | 2 +- .../cloudwatch/components/QueryEditor/QueryHeader.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryEditor.test.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryEditor.test.tsx index a9a7edb80b9..ed093bed858 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryEditor.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryEditor.test.tsx @@ -347,7 +347,7 @@ describe('QueryEditor should render right editor', () => { config.featureToggles.cloudwatchMetricInsightsCrossAccount = true; props.datasource.resources.getAccounts = jest.fn().mockResolvedValue(['account123']); render(); - await screen.findByText('Metric Query'); + await screen.findByText('Metric Insights'); expect(await screen.findByText('Account')).toBeInTheDocument(); }); }); diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx index 7e77f93b4a5..7908c3437ac 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryHeader.tsx @@ -58,12 +58,16 @@ const QueryHeader = ({ onChange({ ...query, region }); } }; + const metricInsightsCrossAccountEnabled = config.featureToggles.cloudwatchMetricInsightsCrossAccount; const shouldDisplayMonitoringBadge = config.featureToggles.cloudWatchCrossAccountQuerying && isMonitoringAccount && (query.queryMode === 'Logs' || - (isCloudWatchMetricsQuery(query) && query.metricQueryType === MetricQueryType.Search)); + (isCloudWatchMetricsQuery(query) && query.metricQueryType === MetricQueryType.Search) || + (metricInsightsCrossAccountEnabled && + isCloudWatchMetricsQuery(query) && + query.metricQueryType === MetricQueryType.Insights)); return ( <>