mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Run queries (#33423)
* alertingqueryrunner first edition * added so we always set name and uid when changing datasource. * wip. * wip * added support for canceling requests. * util for getting time ranges for expression queries * remove logs, store data in state * added structure for marble testing. * change so the expression buttons doesnt submit form. * fixed run button. * replaced mocks with implementation that will set default query + expression. * fixed so we set a datasource name for the default expression rule. * improving expression guard. * Update public/app/features/alerting/components/AlertingQueryEditor.tsx Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * fixed some nits. * some refactoring after feedback. * use grafanthemev2 * rename grafanatheme * fixing so we convert to correct relative time range. * added some more tests. * fixing so duplicating query works. * added some more tests without marbles. * small refactoring to share code between runRequest and alerting query runner. Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import { saveRuleFormAction } from '../../state/actions';
|
||||
import { RuleWithLocation } from 'app/types/unified-alerting';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useCleanup } from 'app/core/hooks/useCleanup';
|
||||
import { rulerRuleToFormValues, defaultFormValues } from '../../utils/rule-form';
|
||||
import { rulerRuleToFormValues, defaultFormValues, getDefaultQueries } from '../../utils/rule-form';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
type Props = {
|
||||
@@ -31,7 +31,10 @@ export const AlertRuleForm: FC<Props> = ({ existing }) => {
|
||||
if (existing) {
|
||||
return rulerRuleToFormValues(existing);
|
||||
}
|
||||
return defaultFormValues;
|
||||
return {
|
||||
...defaultFormValues,
|
||||
queries: getDefaultQueries(),
|
||||
};
|
||||
}, [existing]);
|
||||
|
||||
const formAPI = useForm<RuleFormValues>({
|
||||
|
||||
Reference in New Issue
Block a user