|
|
@ -20,6 +20,7 @@ import ( |
|
|
|
"github.com/grafana/grafana/pkg/services/searchV2/extract" |
|
|
|
"github.com/grafana/grafana/pkg/services/searchV2/extract" |
|
|
|
"github.com/grafana/grafana/pkg/services/sqlstore" |
|
|
|
"github.com/grafana/grafana/pkg/services/sqlstore" |
|
|
|
"github.com/grafana/grafana/pkg/services/store" |
|
|
|
"github.com/grafana/grafana/pkg/services/store" |
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/setting" |
|
|
|
"go.opentelemetry.io/otel/attribute" |
|
|
|
"go.opentelemetry.io/otel/attribute" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/blugelabs/bluge" |
|
|
|
"github.com/blugelabs/bluge" |
|
|
@ -98,9 +99,10 @@ type searchIndex struct { |
|
|
|
syncCh chan chan struct{} |
|
|
|
syncCh chan chan struct{} |
|
|
|
tracer tracing.Tracer |
|
|
|
tracer tracing.Tracer |
|
|
|
features featuremgmt.FeatureToggles |
|
|
|
features featuremgmt.FeatureToggles |
|
|
|
|
|
|
|
settings setting.SearchSettings |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func newSearchIndex(dashLoader dashboardLoader, evStore eventStore, extender DocumentExtender, folderIDs folderUIDLookup, tracer tracing.Tracer, features featuremgmt.FeatureToggles) *searchIndex { |
|
|
|
func newSearchIndex(dashLoader dashboardLoader, evStore eventStore, extender DocumentExtender, folderIDs folderUIDLookup, tracer tracing.Tracer, features featuremgmt.FeatureToggles, settings setting.SearchSettings) *searchIndex { |
|
|
|
return &searchIndex{ |
|
|
|
return &searchIndex{ |
|
|
|
loader: dashLoader, |
|
|
|
loader: dashLoader, |
|
|
|
eventStore: evStore, |
|
|
|
eventStore: evStore, |
|
|
@ -113,6 +115,7 @@ func newSearchIndex(dashLoader dashboardLoader, evStore eventStore, extender Doc |
|
|
|
syncCh: make(chan chan struct{}), |
|
|
|
syncCh: make(chan chan struct{}), |
|
|
|
tracer: tracer, |
|
|
|
tracer: tracer, |
|
|
|
features: features, |
|
|
|
features: features, |
|
|
|
|
|
|
|
settings: settings, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -176,11 +179,13 @@ func (i *searchIndex) sync(ctx context.Context) error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (i *searchIndex) run(ctx context.Context, orgIDs []int64, reIndexSignalCh chan struct{}) error { |
|
|
|
func (i *searchIndex) run(ctx context.Context, orgIDs []int64, reIndexSignalCh chan struct{}) error { |
|
|
|
reIndexInterval := 5 * time.Minute |
|
|
|
i.logger.Info("Initializing SearchV2", "dashboardLoadingBatchSize", i.settings.DashboardLoadingBatchSize, "fullReindexInterval", i.settings.FullReindexInterval, "indexUpdateInterval", i.settings.IndexUpdateInterval) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reIndexInterval := i.settings.FullReindexInterval |
|
|
|
fullReIndexTimer := time.NewTimer(reIndexInterval) |
|
|
|
fullReIndexTimer := time.NewTimer(reIndexInterval) |
|
|
|
defer fullReIndexTimer.Stop() |
|
|
|
defer fullReIndexTimer.Stop() |
|
|
|
|
|
|
|
|
|
|
|
partialUpdateInterval := 5 * time.Second |
|
|
|
partialUpdateInterval := i.settings.IndexUpdateInterval |
|
|
|
partialUpdateTimer := time.NewTimer(partialUpdateInterval) |
|
|
|
partialUpdateTimer := time.NewTimer(partialUpdateInterval) |
|
|
|
defer partialUpdateTimer.Stop() |
|
|
|
defer partialUpdateTimer.Stop() |
|
|
|
|
|
|
|
|
|
|
@ -788,10 +793,11 @@ func (i *searchIndex) updateDashboard(ctx context.Context, orgID int64, index *o |
|
|
|
type sqlDashboardLoader struct { |
|
|
|
type sqlDashboardLoader struct { |
|
|
|
sql *sqlstore.SQLStore |
|
|
|
sql *sqlstore.SQLStore |
|
|
|
logger log.Logger |
|
|
|
logger log.Logger |
|
|
|
|
|
|
|
settings setting.SearchSettings |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func newSQLDashboardLoader(sql *sqlstore.SQLStore) *sqlDashboardLoader { |
|
|
|
func newSQLDashboardLoader(sql *sqlstore.SQLStore, settings setting.SearchSettings) *sqlDashboardLoader { |
|
|
|
return &sqlDashboardLoader{sql: sql, logger: log.New("sqlDashboardLoader")} |
|
|
|
return &sqlDashboardLoader{sql: sql, logger: log.New("sqlDashboardLoader"), settings: settings} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (l sqlDashboardLoader) LoadDashboards(ctx context.Context, orgID int64, dashboardUID string) ([]dashboard, error) { |
|
|
|
func (l sqlDashboardLoader) LoadDashboards(ctx context.Context, orgID int64, dashboardUID string) ([]dashboard, error) { |
|
|
@ -800,7 +806,7 @@ func (l sqlDashboardLoader) LoadDashboards(ctx context.Context, orgID int64, das |
|
|
|
limit := 1 |
|
|
|
limit := 1 |
|
|
|
|
|
|
|
|
|
|
|
if dashboardUID == "" { |
|
|
|
if dashboardUID == "" { |
|
|
|
limit = 200 |
|
|
|
limit = l.settings.DashboardLoadingBatchSize |
|
|
|
dashboards = make([]dashboard, 0, limit+1) |
|
|
|
dashboards = make([]dashboard, 0, limit+1) |
|
|
|
|
|
|
|
|
|
|
|
// Add the root folder ID (does not exist in SQL).
|
|
|
|
// Add the root folder ID (does not exist in SQL).
|
|
|
|