Skip to content

Commit 94a7c15

Browse files
committed
feature: set default Type to instant for alert rules #205
1 parent 3bbac17 commit 94a7c15

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## tip
44

5+
* FEATURE: set the default value of `Type` to `instant` when creating alerting rules. See [this issue](https://github.com/VictoriaMetrics/victoriametrics-datasource/issues/205).
6+
57
## [v0.9.1](https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/tag/v0.9.1)
68

79
* BUGFIX: fix parsing dots in the the `label_values` function in the query builder. See [this issue](https://github.com/VictoriaMetrics/victoriametrics-datasource/issues/198).

src/querybuilder/state.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function getQueryWithDefaults(query: PromQuery, app: CoreApp | undefined)
4242
result = { ...query, editorMode: getDefaultEditorMode(query.expr) };
4343
}
4444

45-
if (query.expr == null) {
45+
if (!query.expr) {
4646
result = { ...result, expr: '', legendFormat: LegendFormatMode.Auto };
4747
}
4848

@@ -56,5 +56,10 @@ export function getQueryWithDefaults(query: PromQuery, app: CoreApp | undefined)
5656
}
5757
}
5858

59+
// Unified Alerting does not support "both" for query type – fall back to "range".
60+
if (app === CoreApp.UnifiedAlerting) {
61+
const isBothInstantAndRange = query.instant && query.range;
62+
result = { ...result, range: isBothInstantAndRange, instant: !isBothInstantAndRange };
63+
}
5964
return result;
6065
}

0 commit comments

Comments
 (0)