Skip to content

Commit

Permalink
feature: set default Type to instant for alert rules #205
Browse files Browse the repository at this point in the history
  • Loading branch information
Loori-R committed Oct 7, 2024
1 parent 3bbac17 commit 94a7c15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## tip

* FEATURE: set the default value of `Type` to `instant` when creating alerting rules. See [this issue](https://github.com/VictoriaMetrics/victoriametrics-datasource/issues/205).

## [v0.9.1](https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/tag/v0.9.1)

* 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).
Expand Down
7 changes: 6 additions & 1 deletion src/querybuilder/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function getQueryWithDefaults(query: PromQuery, app: CoreApp | undefined)
result = { ...query, editorMode: getDefaultEditorMode(query.expr) };
}

if (query.expr == null) {
if (!query.expr) {
result = { ...result, expr: '', legendFormat: LegendFormatMode.Auto };
}

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

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

0 comments on commit 94a7c15

Please sign in to comment.