diff --git a/packages/grafana-schema/src/raw/composable/cloudwatch/dataquery/x/CloudWatchDataQuery_types.gen.ts b/packages/grafana-schema/src/raw/composable/cloudwatch/dataquery/x/CloudWatchDataQuery_types.gen.ts index dc54af845e0..f49b4453da4 100644 --- a/packages/grafana-schema/src/raw/composable/cloudwatch/dataquery/x/CloudWatchDataQuery_types.gen.ts +++ b/packages/grafana-schema/src/raw/composable/cloudwatch/dataquery/x/CloudWatchDataQuery_types.gen.ts @@ -86,7 +86,7 @@ export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat { */ metricEditorMode?: MetricEditorMode; /** - * Whether to use a metric search or metric query. Metric query is referred to as "Metrics Insights" in the AWS console. + * Whether to use a metric search or metric insights query */ metricQueryType?: MetricQueryType; /** @@ -94,11 +94,11 @@ export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat { */ queryMode?: CloudWatchQueryMode; /** - * When the metric query type is `metricQueryType` is set to `Query` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query. + * When the metric query type is set to `Insights` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query. */ sql?: SQLExpression; /** - * When the metric query type is `metricQueryType` is set to `Query`, this field is used to specify the query string. + * When the metric query type is set to `Insights`, this field is used to specify the query string. */ sqlExpression?: string; } @@ -106,7 +106,7 @@ export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat { export type CloudWatchQueryMode = ('Metrics' | 'Logs' | 'Annotations'); export enum MetricQueryType { - Query = 1, + Insights = 1, Search = 0, } diff --git a/pkg/tsdb/cloudwatch/kinds/dataquery/types_dataquery_gen.go b/pkg/tsdb/cloudwatch/kinds/dataquery/types_dataquery_gen.go index a41f2d27536..93a14021487 100644 --- a/pkg/tsdb/cloudwatch/kinds/dataquery/types_dataquery_gen.go +++ b/pkg/tsdb/cloudwatch/kinds/dataquery/types_dataquery_gen.go @@ -271,7 +271,7 @@ type CloudWatchMetricsQuery struct { Region *string `json:"region,omitempty"` Sql *SQLExpression `json:"sql,omitempty"` - // When the metric query type is `metricQueryType` is set to `Query`, this field is used to specify the query string. + // When the metric query type is set to `Insights`, this field is used to specify the query string. SqlExpression *string `json:"sqlExpression,omitempty"` // Metric data aggregations over specified periods of time. For detailed definitions of the statistics supported by CloudWatch, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html. diff --git a/public/app/plugins/datasource/cloudwatch/__mocks__/queries.ts b/public/app/plugins/datasource/cloudwatch/__mocks__/queries.ts index 00c5d4c0d18..36b3a2df017 100644 --- a/public/app/plugins/datasource/cloudwatch/__mocks__/queries.ts +++ b/public/app/plugins/datasource/cloudwatch/__mocks__/queries.ts @@ -44,7 +44,7 @@ export const validMetricQueryBuilderQuery: CloudWatchMetricsQuery = { region: 'us-east-1', namespace: 'ec2', dimensions: { somekey: 'somevalue' }, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Builder, sql: { from: { @@ -77,7 +77,7 @@ export const validMetricQueryCodeQuery: CloudWatchMetricsQuery = { statistic: 'Average', sqlExpression: 'SELECT * FROM "AWS/EC2" WHERE "InstanceId" = \'i-123\'', refId: 'A', - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Code, hide: false, }; diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MetricsQueryEditor.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MetricsQueryEditor.tsx index 6798f650186..83263fac95a 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MetricsQueryEditor.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MetricsQueryEditor.tsx @@ -31,7 +31,7 @@ export interface Props extends QueryEditorProps> = [ { label: 'Metric Search', value: MetricQueryType.Search }, - { label: 'Metric Query', value: MetricQueryType.Query }, + { label: 'Metric Insights', value: MetricQueryType.Insights }, ]; const editorModes = [ { label: 'Builder', value: MetricEditorMode.Builder }, @@ -48,7 +48,7 @@ export const MetricsQueryEditor = (props: Props) => { (newMetricEditorMode: MetricEditorMode) => { if ( codeEditorIsDirty && - query.metricQueryType === MetricQueryType.Query && + query.metricQueryType === MetricQueryType.Insights && query.metricEditorMode === MetricEditorMode.Code ) { setShowConfirm(true); @@ -90,7 +90,7 @@ export const MetricsQueryEditor = (props: Props) => { { onChange({ ...query, ...DEFAULT_METRICS_QUERY, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Builder, }); }} @@ -152,7 +152,7 @@ export const MetricsQueryEditor = (props: Props) => { )} )} - {query.metricQueryType === MetricQueryType.Query && ( + {query.metricQueryType === MetricQueryType.Insights && ( <> {query.metricEditorMode === MetricEditorMode.Code && ( ({ region: 'us-east-1', namespace: 'ec2', dimensions: { somekey: 'somevalue' }, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Builder, sql: sql, }); diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLBuilderSelectRow.test.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLBuilderSelectRow.test.tsx index fc8178311b0..65b709bf72c 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLBuilderSelectRow.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLBuilderSelectRow.test.tsx @@ -16,7 +16,7 @@ const makeSQLQuery = (sql?: SQLExpression): CloudWatchMetricsQuery => ({ region: 'us-east-1', namespace: 'ec2', dimensions: { somekey: 'somevalue' }, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Builder, sql: sql, }); diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLGroupBy.test.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLGroupBy.test.tsx index 388fe8722c6..9f98569e3e7 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLGroupBy.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/SQLBuilderEditor/SQLGroupBy.test.tsx @@ -17,7 +17,7 @@ const makeSQLQuery = (sql?: SQLExpression): CloudWatchMetricsQuery => ({ region: 'us-east-1', namespace: 'ec2', dimensions: { somekey: 'somevalue' }, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Builder, sql: sql, }); 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 7276d65efbc..a9a7edb80b9 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryEditor.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/QueryEditor.test.tsx @@ -21,7 +21,7 @@ import { QueryEditor } from './QueryEditor'; const migratedFields = { statistic: 'Average', metricEditorMode: MetricEditorMode.Builder, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, }; const props: QueryEditorProps = { @@ -201,12 +201,12 @@ describe('QueryEditor should render right editor', () => { describe('should not be displayed when a monitoring account is returned and', () => { const cases: MonitoringBadgeScenario[] = [ { - name: 'it is metric query builder query and toggle is enabled', + name: 'it is metric insights builder query and toggle is enabled', query: validMetricQueryBuilderQuery, toggle: true, }, { - name: 'it is metric query code query and toggle is not enabled', + name: 'it is metric insights code query and toggle is not enabled', query: validMetricQueryCodeQuery, toggle: false, }, @@ -232,24 +232,24 @@ describe('QueryEditor should render right editor', () => { }); describe('QueryHeader', () => { - it('should display metric actions in header when metric query is used', async () => { + it('should display metric actions in header when metric insights is used', async () => { render(); expect(await screen.findByText('CloudWatch Metrics')).toBeInTheDocument(); expect(screen.getByLabelText(/Region.*/)).toBeInTheDocument(); expect(screen.getByLabelText('Builder')).toBeInTheDocument(); expect(screen.getByLabelText('Code')).toBeInTheDocument(); - expect(screen.getByText('Metric Query')).toBeInTheDocument(); + expect(screen.getByText('Metric Insights')).toBeInTheDocument(); }); - it('should display metric actions in header when metric query is used', async () => { + it('should display metric actions in header when metric insights is used', async () => { render(); expect(await screen.findByText('CloudWatch Logs')).toBeInTheDocument(); expect(screen.getByLabelText(/Region.*/)).toBeInTheDocument(); expect(screen.queryByLabelText('Builder')).not.toBeInTheDocument(); expect(screen.queryByLabelText('Code')).not.toBeInTheDocument(); - expect(screen.queryByText('Metric Query')).not.toBeInTheDocument(); + expect(screen.queryByText('Metric Insights')).not.toBeInTheDocument(); }); }); @@ -270,18 +270,18 @@ describe('QueryEditor should render right editor', () => { expect(radio instanceof HTMLInputElement && radio.checked).toBeTruthy(); }); - it('when metric query type is metric query and editor mode is builder', async () => { + it('when metric query type is metric insights and editor mode is builder', async () => { render(); - expect(await screen.findByText('Metric Query')).toBeInTheDocument(); + expect(await screen.findByText('Metric Insights')).toBeInTheDocument(); const radio = screen.getByLabelText('Builder'); expect(radio instanceof HTMLInputElement && radio.checked).toBeTruthy(); }); - it('when metric query type is metric query and editor mode is raw', async () => { + it('when metric query type is metric Insights and editor mode is raw', async () => { render(); - expect(await screen.findByText('Metric Query')).toBeInTheDocument(); + expect(await screen.findByText('Metric Insights')).toBeInTheDocument(); const radio = screen.getByLabelText('Code'); expect(radio instanceof HTMLInputElement && radio.checked).toBeTruthy(); }); diff --git a/public/app/plugins/datasource/cloudwatch/components/shared/MetricStatEditor/MetricStatEditor.tsx b/public/app/plugins/datasource/cloudwatch/components/shared/MetricStatEditor/MetricStatEditor.tsx index 9f9ecd45fdf..63d54a33e56 100644 --- a/public/app/plugins/datasource/cloudwatch/components/shared/MetricStatEditor/MetricStatEditor.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/shared/MetricStatEditor/MetricStatEditor.tsx @@ -26,7 +26,7 @@ const percentileSyntaxRE = /^(p|tm|tc|ts|wm)\d{2}(?:\.\d{1,2})?$/; const boundariesInnerParenthesesSyntax = `\\d*(\\.\\d+)?%?:\\d*(\\.\\d+)?%?`; const boundariesSyntaxRE = new RegExp(`^(PR|TM|TC|TS|WM)\\((${boundariesInnerParenthesesSyntax})\\)$`); -// used in both Metric Query editor and in Annotations Editor +// used in both Metric query editor and in Annotations Editor export const MetricStatEditor = ({ refId, metricStat, diff --git a/public/app/plugins/datasource/cloudwatch/dataquery.cue b/public/app/plugins/datasource/cloudwatch/dataquery.cue index bc3cb0d1821..e1a5277f394 100644 --- a/public/app/plugins/datasource/cloudwatch/dataquery.cue +++ b/public/app/plugins/datasource/cloudwatch/dataquery.cue @@ -56,7 +56,7 @@ composableKinds: DataQuery: { // Whether a query is a Metrics, Logs, or Annotations query queryMode?: #CloudWatchQueryMode - // Whether to use a metric search or metric query. Metric query is referred to as "Metrics Insights" in the AWS console. + // Whether to use a metric search or metric insights query metricQueryType?: #MetricQueryType // Whether to use the query builder or code editor to create the query metricEditorMode?: #MetricEditorMode @@ -69,14 +69,14 @@ composableKinds: DataQuery: { label?: string // Math expression query expression?: string - // When the metric query type is `metricQueryType` is set to `Query`, this field is used to specify the query string. + // When the metric query type is set to `Insights`, this field is used to specify the query string. sqlExpression?: string - // When the metric query type is `metricQueryType` is set to `Query` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query. + // When the metric query type is set to `Insights` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query. sql?: #SQLExpression } @cuetsy(kind="interface") #CloudWatchQueryMode: "Metrics" | "Logs" | "Annotations" @cuetsy(kind="type") - #MetricQueryType: 0 | 1 @cuetsy(kind="enum", memberNames="Search|Query") + #MetricQueryType: 0 | 1 @cuetsy(kind="enum", memberNames="Search|Insights") #MetricEditorMode: 0 | 1 @cuetsy(kind="enum", memberNames="Builder|Code") #SQLExpression: { // SELECT part of the SQL expression diff --git a/public/app/plugins/datasource/cloudwatch/dataquery.gen.ts b/public/app/plugins/datasource/cloudwatch/dataquery.gen.ts index 9cf62e4b588..ff71dad3656 100644 --- a/public/app/plugins/datasource/cloudwatch/dataquery.gen.ts +++ b/public/app/plugins/datasource/cloudwatch/dataquery.gen.ts @@ -84,7 +84,7 @@ export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat { */ metricEditorMode?: MetricEditorMode; /** - * Whether to use a metric search or metric query. Metric query is referred to as "Metrics Insights" in the AWS console. + * Whether to use a metric search or metric insights query */ metricQueryType?: MetricQueryType; /** @@ -92,11 +92,11 @@ export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat { */ queryMode?: CloudWatchQueryMode; /** - * When the metric query type is `metricQueryType` is set to `Query` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query. + * When the metric query type is set to `Insights` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query. */ sql?: SQLExpression; /** - * When the metric query type is `metricQueryType` is set to `Query`, this field is used to specify the query string. + * When the metric query type is set to `Insights`, this field is used to specify the query string. */ sqlExpression?: string; } @@ -104,7 +104,7 @@ export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat { export type CloudWatchQueryMode = ('Metrics' | 'Logs' | 'Annotations'); export enum MetricQueryType { - Query = 1, + Insights = 1, Search = 0, } diff --git a/public/app/plugins/datasource/cloudwatch/migrations/dashboardMigrations.ts b/public/app/plugins/datasource/cloudwatch/migrations/dashboardMigrations.ts index 03da65ed526..d492a5ad3ce 100644 --- a/public/app/plugins/datasource/cloudwatch/migrations/dashboardMigrations.ts +++ b/public/app/plugins/datasource/cloudwatch/migrations/dashboardMigrations.ts @@ -58,7 +58,7 @@ export function migrateCloudWatchQuery(query: CloudWatchMetricsQuery) { } if (!query.hasOwnProperty('metricEditorMode')) { - if (query.metricQueryType === MetricQueryType.Query) { + if (query.metricQueryType === MetricQueryType.Insights) { query.metricEditorMode = MetricEditorMode.Code; } else { query.metricEditorMode = query.expression ? MetricEditorMode.Code : MetricEditorMode.Builder; diff --git a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchMetricsQueryRunner.test.ts b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchMetricsQueryRunner.test.ts index 0ac0bedbc3e..637328f022a 100644 --- a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchMetricsQueryRunner.test.ts +++ b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchMetricsQueryRunner.test.ts @@ -493,7 +493,7 @@ describe('CloudWatchMetricsQueryRunner', () => { matchExact: true, statistic: '', expression: '', - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Code, sqlExpression: 'SELECT SUM($metric) FROM "$namespace" GROUP BY InstanceId,InstanceType LIMIT $limit', }, @@ -734,7 +734,7 @@ describe('CloudWatchMetricsQueryRunner', () => { matchExact: true, statistic: '', expression: '', - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Code, sqlExpression: 'SELECT SUM($metric) FROM "$namespace" GROUP BY ${labels:raw} LIMIT $limit', }; @@ -968,11 +968,11 @@ describe('CloudWatchMetricsQueryRunner', () => { }); }); - describe('metric query queries', () => { + describe('metric insights queries', () => { beforeEach(() => { baseQuery = { ...baseQuery, - metricQueryType: MetricQueryType.Query, + metricQueryType: MetricQueryType.Insights, metricEditorMode: MetricEditorMode.Code, }; }); diff --git a/public/app/plugins/datasource/cloudwatch/tracking.ts b/public/app/plugins/datasource/cloudwatch/tracking.ts index a44c6d866a3..3607b3ef99a 100644 --- a/public/app/plugins/datasource/cloudwatch/tracking.ts +++ b/public/app/plugins/datasource/cloudwatch/tracking.ts @@ -106,12 +106,12 @@ export const onDashboardLoadedHandler = ({ q.metricQueryType === MetricQueryType.Search && q.metricEditorMode === MetricEditorMode.Code ); e.metrics_search_match_exact_count += +Boolean(isMetricSearchBuilder(q) && q.matchExact); - e.metrics_query_count += +Boolean(q.metricQueryType === MetricQueryType.Query); + e.metrics_query_count += +Boolean(q.metricQueryType === MetricQueryType.Insights); e.metrics_query_builder_count += +Boolean( - q.metricQueryType === MetricQueryType.Query && q.metricEditorMode === MetricEditorMode.Builder + q.metricQueryType === MetricQueryType.Insights && q.metricEditorMode === MetricEditorMode.Builder ); e.metrics_query_code_count += +Boolean( - q.metricQueryType === MetricQueryType.Query && q.metricEditorMode === MetricEditorMode.Code + q.metricQueryType === MetricQueryType.Insights && q.metricEditorMode === MetricEditorMode.Code ); e.metrics_queries_with_account_count += +Boolean( config.featureToggles.cloudWatchCrossAccountQuerying && isMetricSearchBuilder(q) && q.accountId diff --git a/public/app/plugins/datasource/cloudwatch/utils/utils.ts b/public/app/plugins/datasource/cloudwatch/utils/utils.ts index 1666c8a3865..b98751ce156 100644 --- a/public/app/plugins/datasource/cloudwatch/utils/utils.ts +++ b/public/app/plugins/datasource/cloudwatch/utils/utils.ts @@ -21,7 +21,7 @@ export const filterMetricsQuery = (query: CloudWatchMetricsQuery): boolean => { return !!namespace && !!metricName && !!statistic; } else if (metricQueryType === MetricQueryType.Search && metricEditorMode === MetricEditorMode.Code) { return !!expression; - } else if (metricQueryType === MetricQueryType.Query) { + } else if (metricQueryType === MetricQueryType.Insights) { // still TBD how to validate the visual query builder for SQL return !!sqlExpression; }