Alerting: Remove feature toggles relating to Loki Alert State History (#103540)
* Remove feature toggles relating to Loki Alert State History
This commit is contained in:
@@ -12,8 +12,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/services/annotations/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -58,8 +56,8 @@ type LokiHistorianStore struct {
|
||||
ruleStore RuleStore
|
||||
}
|
||||
|
||||
func NewLokiHistorianStore(cfg setting.UnifiedAlertingStateHistorySettings, ft featuremgmt.FeatureToggles, db db.DB, ruleStore RuleStore, log log.Logger, tracer tracing.Tracer) *LokiHistorianStore {
|
||||
if !useStore(cfg, ft) {
|
||||
func NewLokiHistorianStore(cfg setting.UnifiedAlertingStateHistorySettings, db db.DB, ruleStore RuleStore, log log.Logger, tracer tracing.Tracer) *LokiHistorianStore {
|
||||
if !useStore(cfg) {
|
||||
return nil
|
||||
}
|
||||
lokiCfg, err := historian.NewLokiConfig(cfg)
|
||||
@@ -294,22 +292,16 @@ func buildHistoryQuery(query *annotations.ItemQuery, dashboards map[string]int64
|
||||
return historyQuery
|
||||
}
|
||||
|
||||
func useStore(cfg setting.UnifiedAlertingStateHistorySettings, ft featuremgmt.FeatureToggles) bool {
|
||||
func useStore(cfg setting.UnifiedAlertingStateHistorySettings) bool {
|
||||
if !cfg.Enabled {
|
||||
return false
|
||||
}
|
||||
|
||||
// Override config based on feature toggles.
|
||||
// We pass in a no-op logger here since this function is also called during ngalert init,
|
||||
// and we don't want to log the same info twice.
|
||||
ngalert.ApplyStateHistoryFeatureToggles(&cfg, ft, log.NewNopLogger())
|
||||
|
||||
backend, err := historian.ParseBackendType(cfg.Backend)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// We should only query Loki if annotations do not exist in the database.
|
||||
// To be doubly sure, ensure that the feature toggle to only use Loki is enabled.
|
||||
return backend == historian.BackendTypeLoki && ft.IsEnabledGlobally(featuremgmt.FlagAlertStateHistoryLokiOnly)
|
||||
return backend == historian.BackendTypeLoki
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user