diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.test.tsx index c715aef67b4..fec1347043d 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.test.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.test.tsx @@ -1,14 +1,13 @@ -import React from 'react'; +import * as ui from '@grafana/ui'; import { render, screen, waitFor } from '@testing-library/react'; +import React from 'react'; import selectEvent from 'react-select-event'; -import QueryEditor from './QueryEditor'; - -import createMockQuery from '../../__mocks__/query'; import createMockDatasource from '../../__mocks__/datasource'; -import { AzureQueryType } from '../../types'; import { invalidNamespaceError } from '../../__mocks__/errors'; -import * as ui from '@grafana/ui'; +import createMockQuery from '../../__mocks__/query'; +import { AzureQueryType, DeprecatedAzureQueryType } from '../../types'; +import QueryEditor from './QueryEditor'; // Have to mock CodeEditor because it doesnt seem to work in tests??? jest.mock('@grafana/ui', () => ({ @@ -45,7 +44,7 @@ describe('Azure Monitor QueryEditor', () => { const mockDatasource = createMockDatasource(); const mockQuery = { ...createMockQuery(), - queryType: AzureQueryType.ApplicationInsights, + queryType: DeprecatedAzureQueryType.ApplicationInsights, appInsights: { metricName: 'requests/count', timeGrain: 'PT1H', @@ -116,7 +115,7 @@ describe('Azure Monitor QueryEditor', () => { const mockDatasource = createMockDatasource(); const mockQuery = { ...createMockQuery(), - queryType: AzureQueryType.ApplicationInsights, + queryType: DeprecatedAzureQueryType.ApplicationInsights, }; render( {}} onRunQuery={() => {}} />); diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.tsx index 1063ca27703..3d74ba05af5 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.tsx @@ -1,23 +1,26 @@ -import { Alert } from '@grafana/ui'; import { QueryEditorProps } from '@grafana/data'; +import { Alert } from '@grafana/ui'; +import { debounce } from 'lodash'; import React, { useCallback, useMemo } from 'react'; + import AzureMonitorDatasource from '../../datasource'; import { + AzureDataSourceJsonData, + AzureMonitorErrorish, + AzureMonitorOption, AzureMonitorQuery, AzureQueryType, - AzureMonitorOption, - AzureMonitorErrorish, - AzureDataSourceJsonData, + DeprecatedAzureQueryType, } from '../../types'; -import MetricsQueryEditor from '../MetricsQueryEditor'; -import QueryTypeField from './QueryTypeField'; import useLastError from '../../utils/useLastError'; -import LogsQueryEditor from '../LogsQueryEditor'; import ArgQueryEditor from '../ArgQueryEditor'; -import ApplicationInsightsEditor from '../ApplicationInsightsEditor'; -import InsightsAnalyticsEditor from '../InsightsAnalyticsEditor'; +import ApplicationInsightsEditor from '../deprecated/components/ApplicationInsightsEditor'; +import InsightsAnalyticsEditor from '../deprecated/components/InsightsAnalyticsEditor'; +import { gtGrafana9 } from '../deprecated/utils'; +import LogsQueryEditor from '../LogsQueryEditor'; +import MetricsQueryEditor from '../MetricsQueryEditor'; import { Space } from '../Space'; -import { debounce } from 'lodash'; +import QueryTypeField from './QueryTypeField'; import usePreparedQuery from './usePreparedQuery'; export type AzureMonitorQueryEditorProps = QueryEditorProps< @@ -115,12 +118,6 @@ const EditorForQueryType: React.FC = ({ /> ); - case AzureQueryType.ApplicationInsights: - return ; - - case AzureQueryType.InsightsAnalytics: - return ; - case AzureQueryType.AzureResourceGraph: return ( = ({ /> ); + /** Remove with Grafana 9 */ + case DeprecatedAzureQueryType.ApplicationInsights: + if (gtGrafana9()) { + return ( + + Application Insights has been deprecated.{' '} + + Use the Metrics service instead + + . + + ); + } + return ; + + case DeprecatedAzureQueryType.InsightsAnalytics: + if (gtGrafana9()) { + return ( + + Insight Analytics has been deprecated.{' '} + + Queries can be written with Kusto in the Logs query type by selecting your Application Insights resource + + . + + ); + } + return ; + /** ===================== */ + default: return ; } diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryTypeField.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryTypeField.tsx index ae56c070c31..d6bdd088398 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryTypeField.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryTypeField.tsx @@ -1,8 +1,10 @@ -import React, { useCallback, useState } from 'react'; -import { Select } from '@grafana/ui'; -import { Field } from '../Field'; -import { AzureMonitorQuery, AzureQueryType } from '../../types'; import { SelectableValue } from '@grafana/data'; +import { Select } from '@grafana/ui'; +import React, { useCallback, useState } from 'react'; + +import { AzureMonitorQuery, AzureQueryType, DeprecatedAzureQueryType } from '../../types'; +import { gtGrafana9 } from '../deprecated/utils'; +import { Field } from '../Field'; interface QueryTypeFieldProps { query: AzureMonitorQuery; @@ -13,24 +15,26 @@ const QueryTypeField: React.FC = ({ query, onQueryChange }) // Use useState to capture the initial value on first mount. We're not interested in when it changes // We only show App Insights and Insights Analytics if they were initially selected. Otherwise, hide them. const [initialQueryType] = useState(query.queryType); - const showAppInsights = - initialQueryType === AzureQueryType.ApplicationInsights || initialQueryType === AzureQueryType.InsightsAnalytics; - const queryTypes = [ + const queryTypes: Array<{ value: AzureQueryType | DeprecatedAzureQueryType; label: string }> = [ { value: AzureQueryType.AzureMonitor, label: 'Metrics' }, { value: AzureQueryType.LogAnalytics, label: 'Logs' }, { value: AzureQueryType.AzureResourceGraph, label: 'Azure Resource Graph' }, ]; - if (showAppInsights) { + if ( + !gtGrafana9() && + (initialQueryType === DeprecatedAzureQueryType.ApplicationInsights || + initialQueryType === DeprecatedAzureQueryType.InsightsAnalytics) + ) { queryTypes.push( - { value: AzureQueryType.ApplicationInsights, label: 'Application Insights' }, - { value: AzureQueryType.InsightsAnalytics, label: 'Insights Analytics' } + { value: DeprecatedAzureQueryType.ApplicationInsights, label: 'Application Insights' }, + { value: DeprecatedAzureQueryType.InsightsAnalytics, label: 'Insights Analytics' } ); } const handleChange = useCallback( - (change: SelectableValue) => { + (change: SelectableValue) => { change.value && onQueryChange({ ...query, diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.test.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/app_insights/app_insights_datasource.test.ts similarity index 100% rename from public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.test.ts rename to public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/app_insights/app_insights_datasource.test.ts diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/app_insights/app_insights_datasource.ts similarity index 93% rename from public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.ts rename to public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/app_insights/app_insights_datasource.ts index c9f7a10a313..15931a06bbf 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/app_insights/app_insights_datasource.ts @@ -1,10 +1,15 @@ import { DataQueryRequest, DataSourceInstanceSettings, ScopedVars } from '@grafana/data'; -import { getTemplateSrv, DataSourceWithBackend } from '@grafana/runtime'; +import { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime'; import { isString } from 'lodash'; -import TimegrainConverter from '../time_grain_converter'; -import { AzureDataSourceJsonData, AzureMonitorQuery, AzureQueryType, DatasourceValidationResult } from '../types'; -import { routeNames } from '../utils/common'; +import TimegrainConverter from '../../../time_grain_converter'; +import { + AzureDataSourceJsonData, + AzureMonitorQuery, + DatasourceValidationResult, + DeprecatedAzureQueryType, +} from '../../../types'; +import { routeNames } from '../../../utils/common'; import ResponseParser from './response_parser'; export interface LogAnalyticsColumn { @@ -94,7 +99,7 @@ export default class AppInsightsDatasource extends DataSourceWithBackend { +const ApplicationInsightsEditor = ({ query }: { query: DeprecatedAzureMonitorQuery }) => { const groupBy = query.appInsights?.dimension || []; return ( diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsAnalyticsEditor/index.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/components/InsightsAnalyticsEditor/index.tsx similarity index 84% rename from public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsAnalyticsEditor/index.tsx rename to public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/components/InsightsAnalyticsEditor/index.tsx index 0bd61c9531d..3c489130394 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsAnalyticsEditor/index.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/components/InsightsAnalyticsEditor/index.tsx @@ -1,11 +1,13 @@ import { Alert, CodeEditor, Select } from '@grafana/ui'; import React from 'react'; -import { AzureMonitorOption, AzureMonitorQuery } from '../../types'; -import { Field } from '../Field'; -import { Space } from '../Space'; + +import { AzureMonitorOption } from '../../../../types'; +import { Field } from '../../../Field'; +import { Space } from '../../../Space'; +import { DeprecatedAzureMonitorQuery } from '../../types'; interface InsightsAnalyticsEditorProps { - query: AzureMonitorQuery; + query: DeprecatedAzureMonitorQuery; } const FORMAT_OPTIONS: Array> = [ diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/insights_analytics/insights_analytics_datasource.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/insights_analytics/insights_analytics_datasource.ts similarity index 64% rename from public/app/plugins/datasource/grafana-azure-monitor-datasource/insights_analytics/insights_analytics_datasource.ts rename to public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/insights_analytics/insights_analytics_datasource.ts index d5f44f57907..32086656594 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/insights_analytics/insights_analytics_datasource.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/insights_analytics/insights_analytics_datasource.ts @@ -1,15 +1,16 @@ -import { ScopedVars, DataSourceInstanceSettings } from '@grafana/data'; +import { DataSourceInstanceSettings, ScopedVars } from '@grafana/data'; import { getTemplateSrv } from '@grafana/runtime'; -import { AzureDataSourceJsonData, AzureMonitorQuery, AzureQueryType } from '../types'; +import { AzureDataSourceJsonData, DeprecatedAzureQueryType } from '../../../types'; import AppInsightsDatasource from '../app_insights/app_insights_datasource'; +import { DeprecatedAzureMonitorQuery } from '../types'; export default class InsightsAnalyticsDatasource extends AppInsightsDatasource { constructor(instanceSettings: DataSourceInstanceSettings) { super(instanceSettings); } - applyTemplateVariables(target: AzureMonitorQuery, scopedVars: ScopedVars): AzureMonitorQuery { + applyTemplateVariables(target: DeprecatedAzureMonitorQuery, scopedVars: ScopedVars): DeprecatedAzureMonitorQuery { const item = target.insightsAnalytics; if (!item) { return target; @@ -19,7 +20,7 @@ export default class InsightsAnalyticsDatasource extends AppInsightsDatasource { return { refId: target.refId, - queryType: AzureQueryType.InsightsAnalytics, + queryType: DeprecatedAzureQueryType.InsightsAnalytics, insightsAnalytics: { query: getTemplateSrv().replace(query, scopedVars), resultFormat: item.resultFormat, diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/types/index.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/types/index.ts new file mode 100644 index 00000000000..a38910e42af --- /dev/null +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/types/index.ts @@ -0,0 +1 @@ +export * from './query'; diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/types/query.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/types/query.ts new file mode 100644 index 00000000000..d8f8fe15235 --- /dev/null +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/deprecated/types/query.ts @@ -0,0 +1,61 @@ +import { DataQuery } from '@grafana/data'; + +import { + AzureLogsQuery, + AzureMetricQuery, + AzureQueryType, + AzureResourceGraphQuery, + DeprecatedAzureQueryType, +} from '../../../types'; +import { GrafanaTemplateVariableQuery } from '../../../types/templateVariables'; + +export interface DeprecatedAzureMonitorQuery extends DataQuery { + queryType?: AzureQueryType | DeprecatedAzureQueryType; + + subscription?: string; + + /** ARG uses multiple subscriptions */ + subscriptions?: string[]; + + azureMonitor?: AzureMetricQuery; + azureLogAnalytics?: AzureLogsQuery; + azureResourceGraph?: AzureResourceGraphQuery; + grafanaTemplateVariableFn?: GrafanaTemplateVariableQuery; + + /** @deprecated App Insights/Insights Analytics deprecated in v8 */ + appInsights?: ApplicationInsightsQuery; + + /** @deprecated App Insights/Insights Analytics deprecated in v8 */ + insightsAnalytics?: InsightsAnalyticsQuery; +} + +/** + * Azure Monitor App Insights sub-query properties + * @deprecated App Insights deprecated in v8 in favor of Metrics queries + */ +export interface ApplicationInsightsQuery { + metricName?: string; + timeGrain?: string; + timeGrainCount?: string; + timeGrainType?: string; + timeGrainUnit?: string; + aggregation?: string; + dimension?: string[]; // Was string before 7.1 + dimensionFilter?: string; + alias?: string; + + /** @deprecated Migrated to Insights Analytics query */ + rawQuery?: string; +} + +/** + * Azure Monitor Insights Analytics sub-query properties + * @deprecated Insights Analytics deprecated in v8 in favor of Logs queries + */ +export interface InsightsAnalyticsQuery { + query?: string; + resultFormat?: string; + + /** @deprecated Migrate field to query */ + rawQueryString?: string; +} diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/datasource.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/datasource.ts index 71564888677..d91ed228338 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/datasource.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/datasource.ts @@ -1,9 +1,3 @@ -import { cloneDeep, upperFirst } from 'lodash'; -import AzureMonitorDatasource from './azure_monitor/azure_monitor_datasource'; -import AppInsightsDatasource from './app_insights/app_insights_datasource'; -import AzureLogAnalyticsDatasource from './azure_log_analytics/azure_log_analytics_datasource'; -import ResourcePickerData from './resourcePicker/resourcePickerData'; -import { AzureDataSourceJsonData, AzureMonitorQuery, AzureQueryType, DatasourceValidationResult } from './types'; import { DataFrame, DataQueryRequest, @@ -13,15 +7,29 @@ import { LoadingState, ScopedVars, } from '@grafana/data'; -import { forkJoin, Observable, of } from 'rxjs'; import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv'; -import InsightsAnalyticsDatasource from './insights_analytics/insights_analytics_datasource'; -import { datasourceMigrations } from './utils/migrateQuery'; +import { cloneDeep, upperFirst } from 'lodash'; +import { forkJoin, Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; + +import AzureLogAnalyticsDatasource from './azure_log_analytics/azure_log_analytics_datasource'; +import AzureMonitorDatasource from './azure_monitor/azure_monitor_datasource'; import AzureResourceGraphDatasource from './azure_resource_graph/azure_resource_graph_datasource'; +import AppInsightsDatasource from './components/deprecated/app_insights/app_insights_datasource'; +import InsightsAnalyticsDatasource from './components/deprecated/insights_analytics/insights_analytics_datasource'; import { getAzureCloud } from './credentials'; +import ResourcePickerData from './resourcePicker/resourcePickerData'; +import { + AzureDataSourceJsonData, + AzureMonitorQuery, + AzureQueryType, + DatasourceValidationResult, + DeprecatedAzureQueryType, +} from './types'; import migrateAnnotation from './utils/migrateAnnotation'; +import { datasourceMigrations } from './utils/migrateQuery'; import { VariableSupport } from './variables'; + export default class Datasource extends DataSourceApi { annotations = { prepareAnnotation: migrateAnnotation, @@ -37,7 +45,7 @@ export default class Datasource extends DataSourceApi): Observable { - const byType = new Map>(); + const byType = new Map>(); for (const baseTarget of options.targets) { // Migrate old query structures @@ -314,10 +322,10 @@ function hasQueryForType(query: AzureMonitorQuery): boolean { case AzureQueryType.GrafanaTemplateVariableFn: return !!query.grafanaTemplateVariableFn; - case AzureQueryType.ApplicationInsights: + case DeprecatedAzureQueryType.ApplicationInsights: return !!query.appInsights; - case AzureQueryType.InsightsAnalytics: + case DeprecatedAzureQueryType.InsightsAnalytics: return !!query.insightsAnalytics; default: diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/types/query.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/types/query.ts index 07f0c0c1bf5..22c208d3cea 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/types/query.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/types/query.ts @@ -1,21 +1,25 @@ -import { DataQuery } from '@grafana/data'; +import { DeprecatedAzureMonitorQuery } from '../components/deprecated/types'; import { GrafanaTemplateVariableQuery } from './templateVariables'; export enum AzureQueryType { AzureMonitor = 'Azure Monitor', - ApplicationInsights = 'Application Insights', - InsightsAnalytics = 'Insights Analytics', LogAnalytics = 'Azure Log Analytics', AzureResourceGraph = 'Azure Resource Graph', GrafanaTemplateVariableFn = 'Grafana Template Variable Function', } +// DeprecatedAzureQueryType won't be available after Grafana 9 +export enum DeprecatedAzureQueryType { + ApplicationInsights = 'Application Insights', + InsightsAnalytics = 'Insights Analytics', +} + /** * Represents the query as it moves through the frontend query editor and datasource files. * It can represent new queries that are still being edited, so all properties are optional */ -export interface AzureMonitorQuery extends DataQuery { - queryType?: AzureQueryType; +export interface AzureMonitorQuery extends DeprecatedAzureMonitorQuery { + queryType?: AzureQueryType | DeprecatedAzureQueryType; subscription?: string; @@ -26,12 +30,6 @@ export interface AzureMonitorQuery extends DataQuery { azureLogAnalytics?: AzureLogsQuery; azureResourceGraph?: AzureResourceGraphQuery; grafanaTemplateVariableFn?: GrafanaTemplateVariableQuery; - - /** @deprecated App Insights/Insights Analytics deprecated in v8 */ - appInsights?: ApplicationInsightsQuery; - - /** @deprecated App Insights/Insights Analytics deprecated in v8 */ - insightsAnalytics?: InsightsAnalyticsQuery; } /** @@ -84,37 +82,6 @@ export interface AzureResourceGraphQuery { resultFormat?: string; } -/** - * Azure Monitor App Insights sub-query properties - * @deprecated App Insights deprecated in v8 in favor of Metrics queries - */ -export interface ApplicationInsightsQuery { - metricName?: string; - timeGrain?: string; - timeGrainCount?: string; - timeGrainType?: string; - timeGrainUnit?: string; - aggregation?: string; - dimension?: string[]; // Was string before 7.1 - dimensionFilter?: string; - alias?: string; - - /** @deprecated Migrated to Insights Analytics query */ - rawQuery?: string; -} - -/** - * Azure Monitor Insights Analytics sub-query properties - * @deprecated Insights Analytics deprecated in v8 in favor of Logs queries - */ -export interface InsightsAnalyticsQuery { - query?: string; - resultFormat?: string; - - /** @deprecated Migrate field to query */ - rawQueryString?: string; -} - export interface AzureMetricDimension { dimension: string; operator: string; diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/migrateQuery.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/migrateQuery.ts index f9f230467ca..3a9043718e0 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/migrateQuery.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/migrateQuery.ts @@ -1,10 +1,10 @@ -import { AzureMonitorQuery, AzureQueryType } from '../types'; -import TimegrainConverter from '../time_grain_converter'; +import { setKustoQuery } from '../components/LogsQueryEditor/setQueryValue'; import { appendDimensionFilter, setTimeGrain as setMetricsTimeGrain, } from '../components/MetricsQueryEditor/setQueryValue'; -import { setKustoQuery } from '../components/LogsQueryEditor/setQueryValue'; +import TimegrainConverter from '../time_grain_converter'; +import { AzureMonitorQuery, AzureQueryType, DeprecatedAzureQueryType } from '../types'; const OLD_DEFAULT_DROPDOWN_VALUE = 'select'; @@ -138,10 +138,10 @@ function migrateMetricsDimensionFilters(query: AzureMonitorQuery): AzureMonitorQ export function datasourceMigrations(query: AzureMonitorQuery): AzureMonitorQuery { let workingQuery = query; - if (workingQuery.queryType === AzureQueryType.ApplicationInsights && workingQuery.appInsights?.rawQuery) { + if (workingQuery.queryType === DeprecatedAzureQueryType.ApplicationInsights && workingQuery.appInsights?.rawQuery) { workingQuery = { ...workingQuery, - queryType: AzureQueryType.InsightsAnalytics, + queryType: DeprecatedAzureQueryType.InsightsAnalytics, appInsights: undefined, insightsAnalytics: { query: workingQuery.appInsights.rawQuery, diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.test.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.test.ts index f63adc557e6..4c927ff84b3 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.test.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.test.ts @@ -1,9 +1,10 @@ import { DataQueryRequest, DataQueryResponseData, toDataFrame } from '@grafana/data'; import { from } from 'rxjs'; -import { AzureMonitorQuery, AzureQueryType } from './types'; -import { VariableSupport } from './variables'; + import createMockDatasource from './__mocks__/datasource'; import { invalidSubscriptionError } from './__mocks__/errors'; +import { AzureMonitorQuery, AzureQueryType } from './types'; +import { VariableSupport } from './variables'; jest.mock('@grafana/runtime', () => ({ ...(jest.requireActual('@grafana/runtime') as unknown as object), diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.ts index 1489942d7fe..2f7b0a41cb8 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/variables.ts @@ -1,4 +1,3 @@ -import { from, lastValueFrom, Observable } from 'rxjs'; import { CustomVariableSupport, DataQueryRequest, @@ -6,13 +5,16 @@ import { MetricFindValue, toDataFrame, } from '@grafana/data'; +import { getTemplateSrv } from '@grafana/runtime'; +import { from, lastValueFrom, Observable } from 'rxjs'; + import VariableEditor from './components/VariableEditor/VariableEditor'; import DataSource from './datasource'; -import { AzureQueryType, AzureMonitorQuery } from './types'; -import { getTemplateSrv } from '@grafana/runtime'; import { migrateStringQueriesToObjectQueries } from './grafanaTemplateVariableFns'; +import { AzureMonitorQuery, AzureQueryType } from './types'; import { GrafanaTemplateVariableQuery } from './types/templateVariables'; import messageFromError from './utils/messageFromError'; + export class VariableSupport extends CustomVariableSupport { constructor(private readonly datasource: DataSource) { super();