Skip to content

Commit

Permalink
feat(alerting): add query optimizations for prometheus (grafana#76015)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyQQQQ authored Oct 17, 2023
1 parent d28e365 commit 2b8c6d6
Show file tree
Hide file tree
Showing 5 changed files with 561 additions and 337 deletions.
6 changes: 3 additions & 3 deletions pkg/services/ngalert/store/alert_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,11 @@ func (st DBstore) GetAlertRulesForScheduling(ctx context.Context, query *ngmodel
// In previous versions of Grafana, Loki datasources would default to range queries
// instead of instant queries, sometimes creating unnecessary load. This is only
// done for Grafana Cloud.
if indices, migratable := canBeInstant(rule); migratable {
if err := migrateToInstant(rule, indices); err != nil {
if optimizations, migratable := canBeInstant(rule); migratable {
if err := migrateToInstant(rule, optimizations); err != nil {
st.Logger.Error("Could not migrate rule from range to instant query", "rule", rule.UID, "err", err)
} else {
st.Logger.Info("Migrated rule from range to instant query", "rule", rule.UID, "migrated_queries", len(indices))
st.Logger.Info("Migrated rule from range to instant query", "rule", rule.UID, "migrated_queries", len(optimizations))
}
}
rules = append(rules, rule)
Expand Down
92 changes: 0 additions & 92 deletions pkg/services/ngalert/store/loki_range_to_instant.go

This file was deleted.

242 changes: 0 additions & 242 deletions pkg/services/ngalert/store/loki_range_to_instant_test.go

This file was deleted.

Loading

0 comments on commit 2b8c6d6

Please sign in to comment.