mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AzureMonitor: Move rest of deprecated code (#46109)
This commit is contained in:
parent
0880e0a472
commit
cfbf58fb92
@ -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(<QueryEditor query={mockQuery} datasource={mockDatasource} onChange={() => {}} onRunQuery={() => {}} />);
|
||||
|
@ -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<EditorForQueryTypeProps> = ({
|
||||
/>
|
||||
);
|
||||
|
||||
case AzureQueryType.ApplicationInsights:
|
||||
return <ApplicationInsightsEditor query={query} />;
|
||||
|
||||
case AzureQueryType.InsightsAnalytics:
|
||||
return <InsightsAnalyticsEditor query={query} />;
|
||||
|
||||
case AzureQueryType.AzureResourceGraph:
|
||||
return (
|
||||
<ArgQueryEditor
|
||||
@ -133,6 +130,44 @@ const EditorForQueryType: React.FC<EditorForQueryTypeProps> = ({
|
||||
/>
|
||||
);
|
||||
|
||||
/** Remove with Grafana 9 */
|
||||
case DeprecatedAzureQueryType.ApplicationInsights:
|
||||
if (gtGrafana9()) {
|
||||
return (
|
||||
<Alert title="Deprecated">
|
||||
Application Insights has been deprecated.{' '}
|
||||
<a
|
||||
href="https://grafana.com/docs/grafana/latest/datasources/azuremonitor/deprecated-application-insights/#application-insights"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Use the Metrics service instead
|
||||
</a>
|
||||
.
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
return <ApplicationInsightsEditor query={query} />;
|
||||
|
||||
case DeprecatedAzureQueryType.InsightsAnalytics:
|
||||
if (gtGrafana9()) {
|
||||
return (
|
||||
<Alert title="Deprecated">
|
||||
Insight Analytics has been deprecated.{' '}
|
||||
<a
|
||||
href="https://grafana.com/docs/grafana/latest/datasources/azuremonitor/deprecated-application-insights/#insights-analytics"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Queries can be written with Kusto in the Logs query type by selecting your Application Insights resource
|
||||
</a>
|
||||
.
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
return <InsightsAnalyticsEditor query={query} />;
|
||||
/** ===================== */
|
||||
|
||||
default:
|
||||
return <Alert title="Unknown query type" />;
|
||||
}
|
||||
|
@ -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<QueryTypeFieldProps> = ({ 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<AzureQueryType>) => {
|
||||
(change: SelectableValue<AzureQueryType | DeprecatedAzureQueryType>) => {
|
||||
change.value &&
|
||||
onQueryChange({
|
||||
...query,
|
||||
|
@ -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<AzureMo
|
||||
|
||||
return {
|
||||
refId: target.refId,
|
||||
queryType: AzureQueryType.ApplicationInsights,
|
||||
queryType: DeprecatedAzureQueryType.ApplicationInsights,
|
||||
appInsights: {
|
||||
timeGrain: templateSrv.replace((item.timeGrain || '').toString(), scopedVars),
|
||||
metricName: templateSrv.replace(item.metricName, scopedVars),
|
@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { AzureMonitorQuery } from '../../types';
|
||||
import { Alert, Input } from '@grafana/ui';
|
||||
import { Field } from '../Field';
|
||||
import React from 'react';
|
||||
|
||||
import { Field } from '../../../Field';
|
||||
import { DeprecatedAzureMonitorQuery } from '../../types';
|
||||
|
||||
const ReadOnlyTimeGrain = ({
|
||||
timeGrainCount,
|
||||
@ -25,7 +26,7 @@ const ReadOnlyTimeGrain = ({
|
||||
);
|
||||
};
|
||||
|
||||
const ApplicationInsightsEditor = ({ query }: { query: AzureMonitorQuery }) => {
|
||||
const ApplicationInsightsEditor = ({ query }: { query: DeprecatedAzureMonitorQuery }) => {
|
||||
const groupBy = query.appInsights?.dimension || [];
|
||||
|
||||
return (
|
@ -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<AzureMonitorOption<string>> = [
|
@ -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<AzureDataSourceJsonData>) {
|
||||
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,
|
@ -0,0 +1 @@
|
||||
export * from './query';
|
@ -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;
|
||||
}
|
@ -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<AzureMonitorQuery, AzureDataSourceJsonData> {
|
||||
annotations = {
|
||||
prepareAnnotation: migrateAnnotation,
|
||||
@ -37,7 +45,7 @@ export default class Datasource extends DataSourceApi<AzureMonitorQuery, AzureDa
|
||||
insightsAnalyticsDatasource?: InsightsAnalyticsDatasource;
|
||||
|
||||
pseudoDatasource: {
|
||||
[key in AzureQueryType]?:
|
||||
[key in AzureQueryType | DeprecatedAzureQueryType]?:
|
||||
| AzureMonitorDatasource
|
||||
| AzureLogAnalyticsDatasource
|
||||
| AzureResourceGraphDatasource
|
||||
@ -68,8 +76,8 @@ export default class Datasource extends DataSourceApi<AzureMonitorQuery, AzureDa
|
||||
// AppInsights and InsightAnalytics are only supported for Public and Azure China clouds
|
||||
this.appInsightsDatasource = new AppInsightsDatasource(instanceSettings);
|
||||
this.insightsAnalyticsDatasource = new InsightsAnalyticsDatasource(instanceSettings);
|
||||
this.pseudoDatasource[AzureQueryType.ApplicationInsights] = this.appInsightsDatasource;
|
||||
this.pseudoDatasource[AzureQueryType.InsightsAnalytics] = this.insightsAnalyticsDatasource;
|
||||
this.pseudoDatasource[DeprecatedAzureQueryType.ApplicationInsights] = this.appInsightsDatasource;
|
||||
this.pseudoDatasource[DeprecatedAzureQueryType.InsightsAnalytics] = this.insightsAnalyticsDatasource;
|
||||
}
|
||||
|
||||
this.variables = new VariableSupport(this);
|
||||
@ -84,7 +92,7 @@ export default class Datasource extends DataSourceApi<AzureMonitorQuery, AzureDa
|
||||
}
|
||||
|
||||
query(options: DataQueryRequest<AzureMonitorQuery>): Observable<DataQueryResponse> {
|
||||
const byType = new Map<AzureQueryType, DataQueryRequest<AzureMonitorQuery>>();
|
||||
const byType = new Map<AzureQueryType | DeprecatedAzureQueryType, DataQueryRequest<AzureMonitorQuery>>();
|
||||
|
||||
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:
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
|
@ -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<DataSource, AzureMonitorQuery> {
|
||||
constructor(private readonly datasource: DataSource) {
|
||||
super();
|
||||
|
Loading…
Reference in New Issue
Block a user