mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
Alerting: rename type to make it obvious what part of the code base it belongs to. (#34714)
* renamed grafana query to grafana alert query. * renamed according to feedback in PR.
This commit is contained in:
@@ -19,14 +19,14 @@ import {
|
||||
import { getNextRefIdChar } from 'app/core/utils/query';
|
||||
import { defaultCondition } from 'app/features/expressions/utils/expressionTypes';
|
||||
import { ExpressionQueryType } from 'app/features/expressions/types';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertingQueryRunner } from '../../state/AlertingQueryRunner';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||
|
||||
interface Props {
|
||||
value?: GrafanaQuery[];
|
||||
onChange: (queries: GrafanaQuery[]) => void;
|
||||
value?: AlertQuery[];
|
||||
onChange: (queries: AlertQuery[]) => void;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -34,7 +34,7 @@ interface State {
|
||||
}
|
||||
export class QueryEditor extends PureComponent<Props, State> {
|
||||
private runner: AlertingQueryRunner;
|
||||
private queries: GrafanaQuery[];
|
||||
private queries: AlertQuery[];
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
@@ -62,12 +62,12 @@ export class QueryEditor extends PureComponent<Props, State> {
|
||||
this.runner.cancel();
|
||||
};
|
||||
|
||||
onChangeQueries = (queries: GrafanaQuery[]) => {
|
||||
onChangeQueries = (queries: AlertQuery[]) => {
|
||||
this.queries = queries;
|
||||
this.props.onChange(queries);
|
||||
};
|
||||
|
||||
onDuplicateQuery = (query: GrafanaQuery) => {
|
||||
onDuplicateQuery = (query: AlertQuery) => {
|
||||
const { queries } = this;
|
||||
this.onChangeQueries(addQuery(queries, query));
|
||||
};
|
||||
@@ -184,13 +184,10 @@ export class QueryEditor extends PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
const addQuery = (
|
||||
queries: GrafanaQuery[],
|
||||
queryToAdd: Pick<GrafanaQuery, 'model' | 'datasourceUid'>
|
||||
): GrafanaQuery[] => {
|
||||
const addQuery = (queries: AlertQuery[], queryToAdd: Pick<AlertQuery, 'model' | 'datasourceUid'>): AlertQuery[] => {
|
||||
const refId = getNextRefIdChar(queries);
|
||||
|
||||
const query: GrafanaQuery = {
|
||||
const query: AlertQuery = {
|
||||
...queryToAdd,
|
||||
refId,
|
||||
queryType: '',
|
||||
|
||||
@@ -3,16 +3,16 @@ import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd';
|
||||
import { DataQuery, DataSourceInstanceSettings, PanelData, RelativeTimeRange } from '@grafana/data';
|
||||
import { getDataSourceSrv } from '@grafana/runtime';
|
||||
import { QueryWrapper } from './QueryWrapper';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
|
||||
interface Props {
|
||||
// The query configuration
|
||||
queries: GrafanaQuery[];
|
||||
queries: AlertQuery[];
|
||||
data: Record<string, PanelData>;
|
||||
|
||||
// Query editing
|
||||
onQueriesChange: (queries: GrafanaQuery[]) => void;
|
||||
onDuplicateQuery: (query: GrafanaQuery) => void;
|
||||
onQueriesChange: (queries: AlertQuery[]) => void;
|
||||
onDuplicateQuery: (query: AlertQuery) => void;
|
||||
onRunQueries: () => void;
|
||||
}
|
||||
|
||||
@@ -119,14 +119,14 @@ export class QueryRows extends PureComponent<Props, State> {
|
||||
onQueriesChange(update);
|
||||
};
|
||||
|
||||
onDuplicateQuery = (query: DataQuery, source: GrafanaQuery): void => {
|
||||
onDuplicateQuery = (query: DataQuery, source: AlertQuery): void => {
|
||||
this.props.onDuplicateQuery({
|
||||
...source,
|
||||
model: query,
|
||||
});
|
||||
};
|
||||
|
||||
getDataSourceSettings = (query: GrafanaQuery): DataSourceInstanceSettings | undefined => {
|
||||
getDataSourceSettings = (query: AlertQuery): DataSourceInstanceSettings | undefined => {
|
||||
return getDataSourceSrv().getInstanceSettings(query.datasourceUid);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,18 +14,18 @@ import { QueryEditorRow } from 'app/features/query/components/QueryEditorRow';
|
||||
import { VizWrapper } from './VizWrapper';
|
||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||
import { TABLE, TIMESERIES } from '../../utils/constants';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
|
||||
interface Props {
|
||||
data: PanelData;
|
||||
query: GrafanaQuery;
|
||||
queries: GrafanaQuery[];
|
||||
query: AlertQuery;
|
||||
queries: AlertQuery[];
|
||||
dsSettings: DataSourceInstanceSettings;
|
||||
onChangeDataSource: (settings: DataSourceInstanceSettings, index: number) => void;
|
||||
onChangeQuery: (query: DataQuery, index: number) => void;
|
||||
onChangeTimeRange?: (timeRange: RelativeTimeRange, index: number) => void;
|
||||
onRemoveQuery: (query: DataQuery) => void;
|
||||
onDuplicateQuery: (query: GrafanaQuery) => void;
|
||||
onDuplicateQuery: (query: AlertQuery) => void;
|
||||
onRunQueries: () => void;
|
||||
index: number;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export const QueryWrapper: FC<Props> = ({
|
||||
const isExpression = isExpressionQuery(query.model);
|
||||
const [pluginId, changePluginId] = useState<SupportedPanelPlugins>(isExpression ? TABLE : TIMESERIES);
|
||||
|
||||
const renderTimePicker = (query: GrafanaQuery, index: number): ReactNode => {
|
||||
const renderTimePicker = (query: AlertQuery, index: number): ReactNode => {
|
||||
if (isExpressionQuery(query.model) || !onChangeTimeRange) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
export const SAMPLE_QUERIES = [
|
||||
{
|
||||
refId: 'A',
|
||||
queryType: '',
|
||||
relativeTimeRange: {
|
||||
from: 21600,
|
||||
to: 0,
|
||||
},
|
||||
datasourceUid: '6_hUDNQGz',
|
||||
model: {
|
||||
intervalMs: 1000,
|
||||
maxDataPoints: 100,
|
||||
pulseWave: {
|
||||
offCount: 6,
|
||||
offValue: 1,
|
||||
onCount: 6,
|
||||
onValue: 10,
|
||||
timeStep: 5,
|
||||
},
|
||||
refId: 'A',
|
||||
scenarioId: 'predictable_pulse',
|
||||
stringInput: '',
|
||||
},
|
||||
},
|
||||
{
|
||||
refId: 'B',
|
||||
queryType: '',
|
||||
relativeTimeRange: {
|
||||
from: 0,
|
||||
to: 0,
|
||||
},
|
||||
datasourceUid: '-100',
|
||||
model: {
|
||||
conditions: [
|
||||
{
|
||||
evaluator: {
|
||||
params: [3],
|
||||
type: 'gt',
|
||||
},
|
||||
operator: {
|
||||
type: 'and',
|
||||
},
|
||||
query: {
|
||||
params: ['A'],
|
||||
},
|
||||
reducer: {
|
||||
type: 'last',
|
||||
},
|
||||
},
|
||||
],
|
||||
intervalMs: 1000,
|
||||
maxDataPoints: 100,
|
||||
refId: 'B',
|
||||
type: 'classic_conditions',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '@grafana/data';
|
||||
import { FetchResponse } from '@grafana/runtime';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
import { delay, take } from 'rxjs/operators';
|
||||
import { createFetchResponse } from 'test/helpers/createFetchResponse';
|
||||
@@ -232,7 +232,7 @@ const createDataFrameJSON = (values: number[]): DataFrameJSON => {
|
||||
};
|
||||
};
|
||||
|
||||
const createQuery = (refId: string): GrafanaQuery => {
|
||||
const createQuery = (refId: string): AlertQuery => {
|
||||
return {
|
||||
refId,
|
||||
queryType: '',
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { FetchResponse, toDataQueryError } from '@grafana/runtime';
|
||||
import { BackendSrv, getBackendSrv } from 'app/core/services/backend_srv';
|
||||
import { preProcessPanelData } from 'app/features/query/state/runRequest';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
import { getTimeRangeForExpression } from '../utils/timeRange';
|
||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||
import { setStructureRevision } from 'app/features/query/state/processing/revision';
|
||||
@@ -41,7 +41,7 @@ export class AlertingQueryRunner {
|
||||
return this.subject.asObservable();
|
||||
}
|
||||
|
||||
run(queries: GrafanaQuery[]) {
|
||||
run(queries: AlertQuery[]) {
|
||||
if (queries.length === 0) {
|
||||
const empty = initialState(queries, LoadingState.Done);
|
||||
return this.subject.next(empty);
|
||||
@@ -99,7 +99,7 @@ export class AlertingQueryRunner {
|
||||
}
|
||||
}
|
||||
|
||||
const runRequest = (backendSrv: BackendSrv, queries: GrafanaQuery[]): Observable<Record<string, PanelData>> => {
|
||||
const runRequest = (backendSrv: BackendSrv, queries: AlertQuery[]): Observable<Record<string, PanelData>> => {
|
||||
const initial = initialState(queries, LoadingState.Loading);
|
||||
const request = {
|
||||
data: { data: queries },
|
||||
@@ -119,7 +119,7 @@ const runRequest = (backendSrv: BackendSrv, queries: GrafanaQuery[]): Observable
|
||||
});
|
||||
};
|
||||
|
||||
const initialState = (queries: GrafanaQuery[], state: LoadingState): Record<string, PanelData> => {
|
||||
const initialState = (queries: AlertQuery[], state: LoadingState): Record<string, PanelData> => {
|
||||
return queries.reduce((dataByQuery: Record<string, PanelData>, query) => {
|
||||
dataByQuery[query.refId] = {
|
||||
state,
|
||||
@@ -131,7 +131,7 @@ const initialState = (queries: GrafanaQuery[], state: LoadingState): Record<stri
|
||||
}, {});
|
||||
};
|
||||
|
||||
const getTimeRange = (query: GrafanaQuery, queries: GrafanaQuery[]): TimeRange => {
|
||||
const getTimeRange = (query: AlertQuery, queries: AlertQuery[]): TimeRange => {
|
||||
if (isExpressionQuery(query.model)) {
|
||||
const relative = getTimeRangeForExpression(query.model, queries);
|
||||
return rangeUtil.relativeToTimeRange(relative);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PanelData } from '@grafana/data';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
import { RuleFormType } from './rule-form';
|
||||
|
||||
export type PreviewRuleRequest = GrafanaPreviewRuleRequest | CloudPreviewRuleRequest;
|
||||
@@ -7,7 +7,7 @@ export type PreviewRuleRequest = GrafanaPreviewRuleRequest | CloudPreviewRuleReq
|
||||
export type GrafanaPreviewRuleRequest = {
|
||||
grafana_condition: {
|
||||
condition: string;
|
||||
data: GrafanaQuery[];
|
||||
data: AlertQuery[];
|
||||
now: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GrafanaQuery, GrafanaAlertStateDecision } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery, GrafanaAlertStateDecision } from 'app/types/unified-alerting-dto';
|
||||
|
||||
export enum RuleFormType {
|
||||
grafana = 'grafana',
|
||||
@@ -15,7 +15,7 @@ export interface RuleFormValues {
|
||||
annotations: Array<{ key: string; value: string }>;
|
||||
|
||||
// grafana rules
|
||||
queries: GrafanaQuery[];
|
||||
queries: AlertQuery[];
|
||||
condition: string | null; // refId of the query that gets alerted on
|
||||
noDataState: GrafanaAlertStateDecision;
|
||||
execErrState: GrafanaAlertStateDecision;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { RuleWithLocation } from 'app/types/unified-alerting';
|
||||
import {
|
||||
Annotations,
|
||||
GrafanaAlertStateDecision,
|
||||
GrafanaQuery,
|
||||
AlertQuery,
|
||||
Labels,
|
||||
PostableRuleGrafanaRuleDTO,
|
||||
RulerAlertingRuleDTO,
|
||||
@@ -135,7 +135,7 @@ export function rulerRuleToFormValues(ruleWithLocation: RuleWithLocation): RuleF
|
||||
}
|
||||
}
|
||||
|
||||
export const getDefaultQueries = (): GrafanaQuery[] => {
|
||||
export const getDefaultQueries = (): AlertQuery[] => {
|
||||
const dataSource = getDataSourceSrv().getInstanceSettings('default');
|
||||
|
||||
if (!dataSource) {
|
||||
@@ -158,7 +158,7 @@ export const getDefaultQueries = (): GrafanaQuery[] => {
|
||||
];
|
||||
};
|
||||
|
||||
const getDefaultExpression = (refId: string): GrafanaQuery => {
|
||||
const getDefaultExpression = (refId: string): AlertQuery => {
|
||||
const model: ExpressionQuery = {
|
||||
refId,
|
||||
hide: false,
|
||||
@@ -197,13 +197,13 @@ const dataQueriesToGrafanaQueries = (
|
||||
queries: DataQuery[],
|
||||
relativeTimeRange: RelativeTimeRange,
|
||||
datasourceName?: string
|
||||
): GrafanaQuery[] => {
|
||||
return queries.reduce<GrafanaQuery[]>((queries, target) => {
|
||||
): AlertQuery[] => {
|
||||
return queries.reduce<AlertQuery[]>((queries, target) => {
|
||||
const dsName = target.datasource || datasourceName;
|
||||
if (dsName) {
|
||||
// expressions
|
||||
if (dsName === ExpressionDatasourceID) {
|
||||
const newQuery: GrafanaQuery = {
|
||||
const newQuery: AlertQuery = {
|
||||
refId: target.refId,
|
||||
queryType: '',
|
||||
relativeTimeRange,
|
||||
@@ -215,7 +215,7 @@ const dataQueriesToGrafanaQueries = (
|
||||
} else {
|
||||
const datasource = getDataSourceSrv().getInstanceSettings(target.datasource || datasourceName);
|
||||
if (datasource && datasource.meta.alerting) {
|
||||
const newQuery: GrafanaQuery = {
|
||||
const newQuery: AlertQuery = {
|
||||
refId: target.refId,
|
||||
queryType: target.queryType ?? '',
|
||||
relativeTimeRange,
|
||||
|
||||
@@ -2,13 +2,13 @@ import { ReducerID } from '@grafana/data';
|
||||
import { getTimeRangeForExpression } from './timeRange';
|
||||
import { defaultCondition } from 'app/features/expressions/utils/expressionTypes';
|
||||
import { ExpressionQuery, ExpressionQueryType } from 'app/features/expressions/types';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
|
||||
describe('timeRange', () => {
|
||||
describe('getTimeRangeForExpression', () => {
|
||||
describe('classic condition', () => {
|
||||
it('should return referenced query timeRange for classic condition', () => {
|
||||
const expressionQuery: GrafanaQuery = {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
@@ -20,14 +20,14 @@ describe('timeRange', () => {
|
||||
type: ExpressionQueryType.classic,
|
||||
} as ExpressionQuery,
|
||||
};
|
||||
const query: GrafanaQuery = {
|
||||
const query: AlertQuery = {
|
||||
refId: 'A',
|
||||
relativeTimeRange: { from: 300, to: 0 },
|
||||
queryType: 'query',
|
||||
datasourceUid: 'dsuid',
|
||||
model: { refId: 'A' },
|
||||
};
|
||||
const queries: GrafanaQuery[] = [query, expressionQuery];
|
||||
const queries: AlertQuery[] = [query, expressionQuery];
|
||||
|
||||
expect(getTimeRangeForExpression(expressionQuery.model as ExpressionQuery, queries)).toEqual({
|
||||
from: 300,
|
||||
@@ -36,7 +36,7 @@ describe('timeRange', () => {
|
||||
});
|
||||
|
||||
it('should return the min and max time range', () => {
|
||||
const expressionQuery: GrafanaQuery = {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'C',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
@@ -51,21 +51,21 @@ describe('timeRange', () => {
|
||||
type: ExpressionQueryType.classic,
|
||||
} as ExpressionQuery,
|
||||
};
|
||||
const queryA: GrafanaQuery = {
|
||||
const queryA: AlertQuery = {
|
||||
refId: 'A',
|
||||
relativeTimeRange: { from: 300, to: 0 },
|
||||
datasourceUid: 'dsuid',
|
||||
model: { refId: 'A' },
|
||||
queryType: 'query',
|
||||
};
|
||||
const queryB: GrafanaQuery = {
|
||||
const queryB: AlertQuery = {
|
||||
refId: 'B',
|
||||
relativeTimeRange: { from: 600, to: 300 },
|
||||
datasourceUid: 'dsuid',
|
||||
model: { refId: 'B' },
|
||||
queryType: 'query',
|
||||
};
|
||||
const queries: GrafanaQuery[] = [queryA, queryB, expressionQuery];
|
||||
const queries: AlertQuery[] = [queryA, queryB, expressionQuery];
|
||||
|
||||
expect(getTimeRangeForExpression(expressionQuery.model as ExpressionQuery, queries)).toEqual({
|
||||
from: 600,
|
||||
@@ -76,7 +76,7 @@ describe('timeRange', () => {
|
||||
});
|
||||
describe('math', () => {
|
||||
it('should get timerange for referenced query', () => {
|
||||
const expressionQuery: GrafanaQuery = {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
@@ -89,7 +89,7 @@ describe('timeRange', () => {
|
||||
} as ExpressionQuery,
|
||||
};
|
||||
|
||||
const query: GrafanaQuery = {
|
||||
const query: AlertQuery = {
|
||||
refId: 'A',
|
||||
datasourceUid: 'dsuid',
|
||||
relativeTimeRange: { from: 300, to: 0 },
|
||||
@@ -101,7 +101,7 @@ describe('timeRange', () => {
|
||||
});
|
||||
|
||||
it('should get time ranges for multiple referenced queries', () => {
|
||||
const expressionQuery: GrafanaQuery = {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'C',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
@@ -114,7 +114,7 @@ describe('timeRange', () => {
|
||||
} as ExpressionQuery,
|
||||
};
|
||||
|
||||
const queryA: GrafanaQuery = {
|
||||
const queryA: AlertQuery = {
|
||||
refId: 'A',
|
||||
relativeTimeRange: { from: 300, to: 0 },
|
||||
datasourceUid: 'dsuid',
|
||||
@@ -122,7 +122,7 @@ describe('timeRange', () => {
|
||||
queryType: 'query',
|
||||
};
|
||||
|
||||
const queryB: GrafanaQuery = {
|
||||
const queryB: AlertQuery = {
|
||||
refId: 'queryB',
|
||||
relativeTimeRange: { from: 600, to: 300 },
|
||||
datasourceUid: 'dsuid',
|
||||
@@ -138,7 +138,7 @@ describe('timeRange', () => {
|
||||
|
||||
describe('resample', () => {
|
||||
it('should get referenced timerange for resample expression', () => {
|
||||
const expressionQuery: GrafanaQuery = {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
@@ -152,7 +152,7 @@ describe('timeRange', () => {
|
||||
} as ExpressionQuery,
|
||||
};
|
||||
|
||||
const queryA: GrafanaQuery = {
|
||||
const queryA: AlertQuery = {
|
||||
refId: 'A',
|
||||
relativeTimeRange: { from: 300, to: 0 },
|
||||
datasourceUid: 'dsuid',
|
||||
@@ -171,7 +171,7 @@ describe('timeRange', () => {
|
||||
|
||||
describe('reduce', () => {
|
||||
it('should get referenced timerange for reduce expression', () => {
|
||||
const expressionQuery: GrafanaQuery = {
|
||||
const expressionQuery: AlertQuery = {
|
||||
refId: 'B',
|
||||
queryType: 'expression',
|
||||
datasourceUid: '-100',
|
||||
@@ -185,7 +185,7 @@ describe('timeRange', () => {
|
||||
} as ExpressionQuery,
|
||||
};
|
||||
|
||||
const queryA: GrafanaQuery = {
|
||||
const queryA: AlertQuery = {
|
||||
refId: 'A',
|
||||
relativeTimeRange: { from: 300, to: 0 },
|
||||
datasourceUid: 'dsuid',
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { RelativeTimeRange } from '@grafana/data';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||
import { ExpressionQuery, ExpressionQueryType } from '../../../expressions/types';
|
||||
|
||||
const FALL_BACK_TIME_RANGE = { from: 21600, to: 0 };
|
||||
|
||||
export const getTimeRangeForExpression = (query: ExpressionQuery, queries: GrafanaQuery[]): RelativeTimeRange => {
|
||||
export const getTimeRangeForExpression = (query: ExpressionQuery, queries: AlertQuery[]): RelativeTimeRange => {
|
||||
const referencedRefIds: string[] | undefined = getReferencedIds(query, queries);
|
||||
|
||||
if (!referencedRefIds) {
|
||||
@@ -23,7 +23,7 @@ export const getTimeRangeForExpression = (query: ExpressionQuery, queries: Grafa
|
||||
};
|
||||
};
|
||||
|
||||
const getReferencedIds = (model: ExpressionQuery, queries: GrafanaQuery[]): string[] | undefined => {
|
||||
const getReferencedIds = (model: ExpressionQuery, queries: AlertQuery[]): string[] | undefined => {
|
||||
switch (model.type) {
|
||||
case ExpressionQueryType.classic:
|
||||
return getReferencedIdsForClassicCondition(model);
|
||||
@@ -41,7 +41,7 @@ const getReferencedIdsForClassicCondition = (model: ExpressionQuery) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getTimeRanges = (referencedRefIds: string[], queries: GrafanaQuery[]) => {
|
||||
const getTimeRanges = (referencedRefIds: string[], queries: AlertQuery[]) => {
|
||||
let from: number[] = [];
|
||||
let to = [FALL_BACK_TIME_RANGE.to];
|
||||
for (const referencedRefIdsKey of referencedRefIds) {
|
||||
@@ -60,7 +60,7 @@ const getTimeRanges = (referencedRefIds: string[], queries: GrafanaQuery[]) => {
|
||||
};
|
||||
};
|
||||
|
||||
const getReferencedIdsForMath = (model: ExpressionQuery, queries: GrafanaQuery[]) => {
|
||||
const getReferencedIdsForMath = (model: ExpressionQuery, queries: AlertQuery[]) => {
|
||||
return (
|
||||
queries
|
||||
// filter queries of type query and filter expression on if it includes any refIds
|
||||
|
||||
@@ -101,7 +101,7 @@ export enum GrafanaAlertStateDecision {
|
||||
OK = 'OK',
|
||||
}
|
||||
|
||||
export interface GrafanaQuery {
|
||||
export interface AlertQuery {
|
||||
refId: string;
|
||||
queryType: string;
|
||||
relativeTimeRange?: RelativeTimeRange;
|
||||
@@ -115,7 +115,7 @@ export interface PostableGrafanaRuleDefinition {
|
||||
condition: string;
|
||||
no_data_state: GrafanaAlertStateDecision;
|
||||
exec_err_state: GrafanaAlertStateDecision;
|
||||
data: GrafanaQuery[];
|
||||
data: AlertQuery[];
|
||||
}
|
||||
export interface GrafanaRuleDefinition extends PostableGrafanaRuleDefinition {
|
||||
uid: string;
|
||||
|
||||
Reference in New Issue
Block a user