Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default Type to instant for alert rules #207

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 query 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;
}
Loading