diff --git a/conf/defaults.ini b/conf/defaults.ini index d09dfe3c428..83a0a719708 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -672,6 +672,9 @@ max_annotation_age = max_annotations_to_keep = #################################### Annotations ######################### +[annotations] +# Configures the batch size for the annotation clean-up job. This setting is used for dashboard, API, and alert annotations. +cleanupjob_batchsize = 100 [annotations.dashboard] # Dashboard annotations means that annotations are associated with the dashboard they are created on. diff --git a/conf/sample.ini b/conf/sample.ini index 80bae2091de..bfe086e1f87 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -665,6 +665,9 @@ ;max_annotations_to_keep = #################################### Annotations ######################### +[annotations] +# Configures the batch size for the annotation clean-up job. This setting is used for dashboard, API, and alert annotations. +;cleanupjob_batchsize = 100 [annotations.dashboard] # Dashboard annotations means that annotations are associated with the dashboard they are created on. diff --git a/docs/sources/administration/configuration.md b/docs/sources/administration/configuration.md index 5d05b489084..889a9c7eb42 100644 --- a/docs/sources/administration/configuration.md +++ b/docs/sources/administration/configuration.md @@ -1052,6 +1052,12 @@ Configures max number of alert annotations that Grafana stores. Default value is
+## [annotations] + +### cleanupjob_batchsize + +Configures the batch size for the annotation clean-up job. This setting is used for dashboard, API, and alert annotations. + ## [annotations.dashboard] Dashboard annotations means that annotations are associated with the dashboard they are created on. diff --git a/pkg/services/sqlstore/sqlstore.go b/pkg/services/sqlstore/sqlstore.go index 6331be78a8d..c8ac9b2294d 100644 --- a/pkg/services/sqlstore/sqlstore.go +++ b/pkg/services/sqlstore/sqlstore.go @@ -105,7 +105,7 @@ func (ss *SQLStore) Init() error { // Init repo instances annotations.SetRepository(&SQLAnnotationRepo{}) - annotations.SetAnnotationCleaner(&AnnotationCleanupService{batchSize: 100, log: log.New("annotationcleaner")}) + annotations.SetAnnotationCleaner(&AnnotationCleanupService{batchSize: ss.Cfg.AnnotationCleanupJobBatchSize, log: log.New("annotationcleaner")}) ss.Bus.SetTransactionManager(ss) // Register handlers diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 7055a156b66..2e8a09e8cc2 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -314,6 +314,7 @@ type Cfg struct { HiddenUsers map[string]struct{} // Annotations + AnnotationCleanupJobBatchSize int64 AlertingAnnotationCleanupSetting AnnotationCleanupSettings DashboardAnnotationCleanupSettings AnnotationCleanupSettings APIAnnotationCleanupSettings AnnotationCleanupSettings @@ -467,6 +468,9 @@ func (cfg *Cfg) readGrafanaEnvironmentMetrics() error { } func (cfg *Cfg) readAnnotationSettings() { + section := cfg.Raw.Section("annotations") + cfg.AnnotationCleanupJobBatchSize = section.Key("cleanupjob_batchsize").MustInt64(100) + dashboardAnnotation := cfg.Raw.Section("annotations.dashboard") apiIAnnotation := cfg.Raw.Section("annotations.api") alertingSection := cfg.Raw.Section("alerting")