Annotation: Optionally allow storing longer annotation tags (#54754)
* Annotation: Optionally allow longer annotation tags * Do not accept configuration lower than today's default (500) * Apply suggestion from code review
This commit is contained in:
+19
-2
@@ -374,6 +374,7 @@ type Cfg struct {
|
||||
|
||||
// Annotations
|
||||
AnnotationCleanupJobBatchSize int64
|
||||
AnnotationMaximumTagsLength int64
|
||||
AlertingAnnotationCleanupSetting AnnotationCleanupSettings
|
||||
DashboardAnnotationCleanupSettings AnnotationCleanupSettings
|
||||
APIAnnotationCleanupSettings AnnotationCleanupSettings
|
||||
@@ -601,9 +602,20 @@ func (cfg *Cfg) readGrafanaEnvironmentMetrics() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readAnnotationSettings() {
|
||||
func (cfg *Cfg) readAnnotationSettings() error {
|
||||
section := cfg.Raw.Section("annotations")
|
||||
cfg.AnnotationCleanupJobBatchSize = section.Key("cleanupjob_batchsize").MustInt64(100)
|
||||
cfg.AnnotationMaximumTagsLength = section.Key("tags_length").MustInt64(500)
|
||||
switch {
|
||||
case cfg.AnnotationMaximumTagsLength > 4096:
|
||||
// ensure that the configuration does not exceed the respective column size
|
||||
return fmt.Errorf("[annotations.tags_length] configuration exceeds the maximum allowed (4096)")
|
||||
case cfg.AnnotationMaximumTagsLength > 500:
|
||||
cfg.Logger.Info("[annotations.tags_length] has been increased from its default value; this may affect the performance", "tagLength", cfg.AnnotationMaximumTagsLength)
|
||||
case cfg.AnnotationMaximumTagsLength < 500:
|
||||
cfg.Logger.Warn("[annotations.tags_length] is too low; the minimum allowed (500) is enforced")
|
||||
cfg.AnnotationMaximumTagsLength = 500
|
||||
}
|
||||
|
||||
dashboardAnnotation := cfg.Raw.Section("annotations.dashboard")
|
||||
apiIAnnotation := cfg.Raw.Section("annotations.api")
|
||||
@@ -624,6 +636,8 @@ func (cfg *Cfg) readAnnotationSettings() {
|
||||
cfg.AlertingAnnotationCleanupSetting = newAnnotationCleanupSettings(alertingSection, "max_annotation_age")
|
||||
cfg.DashboardAnnotationCleanupSettings = newAnnotationCleanupSettings(dashboardAnnotation, "max_age")
|
||||
cfg.APIAnnotationCleanupSettings = newAnnotationCleanupSettings(apiIAnnotation, "max_age")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readExpressionsSettings() {
|
||||
@@ -1020,7 +1034,10 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
|
||||
cfg.readSessionConfig()
|
||||
cfg.readSmtpSettings()
|
||||
cfg.readQuotaSettings()
|
||||
cfg.readAnnotationSettings()
|
||||
if err := cfg.readAnnotationSettings(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg.readExpressionsSettings()
|
||||
if err := cfg.readGrafanaEnvironmentMetrics(); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user