mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): enable loki query optimization by default (#74739)
This commit is contained in:
parent
99be6fb747
commit
f3b6d01306
@ -117,7 +117,6 @@ Experimental features might be changed or removed without prior notice.
|
||||
| `exploreScrollableLogsContainer` | Improves the scrolling behavior of logs in Explore |
|
||||
| `recordedQueriesMulti` | Enables writing multiple items from a single query within Recorded Queries |
|
||||
| `pluginsDynamicAngularDetectionPatterns` | Enables fetching Angular detection patterns for plugins from GCOM and fallback to hardcoded ones |
|
||||
| `alertingLokiRangeToInstant` | Rewrites eligible loki range queries to instant queries |
|
||||
| `vizAndWidgetSplit` | Split panels between vizualizations and widgets |
|
||||
| `prometheusIncrementalQueryInstrumentation` | Adds RudderStack events to incremental queries |
|
||||
| `logsExploreTableVisualisation` | A table visualisation for logs in Explore |
|
||||
|
@ -97,7 +97,6 @@ export interface FeatureToggles {
|
||||
exploreScrollableLogsContainer?: boolean;
|
||||
recordedQueriesMulti?: boolean;
|
||||
pluginsDynamicAngularDetectionPatterns?: boolean;
|
||||
alertingLokiRangeToInstant?: boolean;
|
||||
vizAndWidgetSplit?: boolean;
|
||||
prometheusIncrementalQueryInstrumentation?: boolean;
|
||||
logsExploreTableVisualisation?: boolean;
|
||||
|
@ -542,13 +542,6 @@ var (
|
||||
FrontendOnly: false,
|
||||
Owner: grafanaPluginsPlatformSquad,
|
||||
},
|
||||
{
|
||||
Name: "alertingLokiRangeToInstant",
|
||||
Description: "Rewrites eligible loki range queries to instant queries",
|
||||
Stage: FeatureStageExperimental,
|
||||
FrontendOnly: false,
|
||||
Owner: grafanaAlertingSquad,
|
||||
},
|
||||
{
|
||||
Name: "vizAndWidgetSplit",
|
||||
Description: "Split panels between vizualizations and widgets",
|
||||
|
@ -78,7 +78,6 @@ cloudWatchLogsMonacoEditor,preview,@grafana/aws-datasources,false,false,false,tr
|
||||
exploreScrollableLogsContainer,experimental,@grafana/observability-logs,false,false,false,true
|
||||
recordedQueriesMulti,experimental,@grafana/observability-metrics,false,false,false,false
|
||||
pluginsDynamicAngularDetectionPatterns,experimental,@grafana/plugins-platform-backend,false,false,false,false
|
||||
alertingLokiRangeToInstant,experimental,@grafana/alerting-squad,false,false,false,false
|
||||
vizAndWidgetSplit,experimental,@grafana/dashboards-squad,false,false,false,true
|
||||
prometheusIncrementalQueryInstrumentation,experimental,@grafana/observability-metrics,false,false,false,true
|
||||
logsExploreTableVisualisation,experimental,@grafana/observability-logs,false,false,false,true
|
||||
|
|
@ -323,10 +323,6 @@ const (
|
||||
// Enables fetching Angular detection patterns for plugins from GCOM and fallback to hardcoded ones
|
||||
FlagPluginsDynamicAngularDetectionPatterns = "pluginsDynamicAngularDetectionPatterns"
|
||||
|
||||
// FlagAlertingLokiRangeToInstant
|
||||
// Rewrites eligible loki range queries to instant queries
|
||||
FlagAlertingLokiRangeToInstant = "alertingLokiRangeToInstant"
|
||||
|
||||
// FlagVizAndWidgetSplit
|
||||
// Split panels between vizualizations and widgets
|
||||
FlagVizAndWidgetSplit = "vizAndWidgetSplit"
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
"github.com/grafana/grafana/pkg/services/search/model"
|
||||
@ -540,7 +539,6 @@ func (st DBstore) GetAlertRulesForScheduling(ctx context.Context, query *ngmodel
|
||||
st.Logger.Error("Unable to close rows session", "error", err)
|
||||
}
|
||||
}()
|
||||
lokiRangeToInstantEnabled := st.FeatureToggles.IsEnabled(featuremgmt.FlagAlertingLokiRangeToInstant)
|
||||
// Deserialize each rule separately in case any of them contain invalid JSON.
|
||||
for rows.Next() {
|
||||
rule := new(ngmodels.AlertRule)
|
||||
@ -553,13 +551,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 lokiRangeToInstantEnabled {
|
||||
if indices, migratable := canBeInstant(rule); migratable {
|
||||
if err := migrateToInstant(rule, indices); 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))
|
||||
}
|
||||
if indices, migratable := canBeInstant(rule); migratable {
|
||||
if err := migrateToInstant(rule, indices); 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))
|
||||
}
|
||||
}
|
||||
rules = append(rules, rule)
|
||||
|
Loading…
Reference in New Issue
Block a user