diff --git a/cmd/jaeger/config-elasticsearch.yaml b/cmd/jaeger/config-elasticsearch.yaml index 5663b246cce..d18fb302126 100644 --- a/cmd/jaeger/config-elasticsearch.yaml +++ b/cmd/jaeger/config-elasticsearch.yaml @@ -32,6 +32,9 @@ extensions: backends: some_storage: elasticsearch: + rollover: + enabled: true + frequency: "week" indices: index_prefix: "jaeger-main" spans: diff --git a/pkg/es/config/config.go b/pkg/es/config/config.go index 8d2dbd3236f..fb31fba8f4e 100644 --- a/pkg/es/config/config.go +++ b/pkg/es/config/config.go @@ -158,7 +158,7 @@ type Configuration struct { // IndexCleaner holds the configuration for the Elasticsearch index Cleaner. IndexCleaner IndexCleaner `mapstructure:"index_cleaner"` // Rollover holds the configuration for the Elasticsearh roll over. - Rollover Rollover `mapstructure:"roll_over"` + Rollover Rollover `mapstructure:"rollover"` } // TagsAsFields holds configuration for tag schema. diff --git a/plugin/storage/es/index_cleaner.go b/plugin/storage/es/index_cleaner.go index 8dd090281f5..cb07dbe22f8 100644 --- a/plugin/storage/es/index_cleaner.go +++ b/plugin/storage/es/index_cleaner.go @@ -4,6 +4,7 @@ package es import ( + "errors" "fmt" "log" "os/exec" @@ -39,14 +40,10 @@ func (cfg *CleanerConfigWrapper) RunCleaner() { // runESIndexCleaner runs the cmd/es-index-cleaner command. func (cfg *CleanerConfigWrapper) runESIndexCleaner() error { if len(cfg.Servers) == 0 { - return fmt.Errorf("elasticsearch server URL is missing in configuration") + return errors.New("elasticsearch server URL is missing in configuration") } - esURL := cfg.Servers[0] - numOfDays := int(cfg.MaxSpanAge.Hours() / 24) - - cmd := exec.Command("./cmd/es-index-cleaner", fmt.Sprintf("%d", numOfDays), esURL) - cmd.Args = append(cmd.Args, "--max-span-age", cfg.MaxSpanAge.String()) + cmd := exec.Command("./cmd/es-index-cleaner") err := cmd.Run() if err != nil { diff --git a/plugin/storage/es/index_rollover.go b/plugin/storage/es/index_rollover.go index 4ac6d45459f..313ef3ade10 100644 --- a/plugin/storage/es/index_rollover.go +++ b/plugin/storage/es/index_rollover.go @@ -4,7 +4,6 @@ package es import ( - "fmt" "log" "os/exec" "time" @@ -29,22 +28,13 @@ func (cfg *RolloverConfigWrapper) RunRollover() { for range ticker.C { log.Println("Running index rollover...") - err := cfg.runEsRollover() + cmd := exec.Command("./cmd/es-rollover") + err := cmd.Run() + if err != nil { log.Printf("Error running es-rollover: %v", err) + } else { + log.Println("Index rollover executed successfully.") } } } - -// runEsRollover executes the rollover tool. -func (cfg *RolloverConfigWrapper) runEsRollover() error { - cmd := exec.Command("./cmd/es-rollover") - - err := cmd.Run() - if err != nil { - return fmt.Errorf("failed to run es-rollover: %w", err) - } - - log.Println("Index rollover executed successfully") - return nil -}