mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 14:14:23 +02:00
add ilm forecast data collection, generalized parallel api calls
This commit is contained in:
61
cmd/ilm.go
61
cmd/ilm.go
@@ -37,6 +37,7 @@ func Ilm(conf *cfg.Config) *cli.Command {
|
||||
IlmList(conf),
|
||||
IlmShow(conf),
|
||||
IlmCreate(conf),
|
||||
IlmForecast(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -99,66 +100,6 @@ func IlmShow(conf *cfg.Config) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
"hot": {
|
||||
"min_age": "0ms",
|
||||
"actions": {
|
||||
"rollover": {
|
||||
"max_primary_shard_size": "50gb",
|
||||
"max_age": "1d",
|
||||
"max_docs": 100000000
|
||||
},
|
||||
"set_priority": {
|
||||
"priority": 100
|
||||
}
|
||||
}
|
||||
},
|
||||
"warm": {
|
||||
"min_age": "7d",
|
||||
"actions": {
|
||||
"migrate": {},
|
||||
"shrink": {
|
||||
"number_of_shards": 1
|
||||
},
|
||||
"forcemerge": {
|
||||
"max_num_segments": 1
|
||||
},
|
||||
"set_priority": {
|
||||
"priority": 50
|
||||
}
|
||||
}
|
||||
},
|
||||
"cold": {
|
||||
"min_age": "30d",
|
||||
"actions": {
|
||||
"migrate": {},
|
||||
"searchable_snapshot": {
|
||||
"snapshot_repository": "s3-logs-archive",
|
||||
"force_merge_index": true
|
||||
},
|
||||
"set_priority": {
|
||||
"priority": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"min_age": "90d",
|
||||
"actions": {
|
||||
"delete": {
|
||||
"delete_searchable_snapshot": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
func IlmCreate(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "create",
|
||||
|
||||
71
cmd/ilm_forecast.go
Normal file
71
cmd/ilm_forecast.go
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright © 2026 Thomas von Dein
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
"codeberg.org/scip/esctl/pkg/es"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func IlmForecast(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "forecast",
|
||||
Usage: "calculate index phase movements",
|
||||
|
||||
Commands: []*cli.Command{
|
||||
IlmForecastList(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IlmForecastList(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "list index rollover config",
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "from-phase",
|
||||
Usage: "which ilm phase to forecast from",
|
||||
Destination: &conf.Ilm.FromPhase,
|
||||
Aliases: []string{"f"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "within",
|
||||
Usage: "duration withing which to forecast",
|
||||
Destination: &conf.Ilm.Within,
|
||||
Aliases: []string{"w"},
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
valid := []string{"hot", "warm", "cold", "frozen"}
|
||||
if !slices.Contains(valid, conf.Ilm.FromPhase) {
|
||||
return errors.New("invalid from phase, allowed: hot, warm, cold, frozen")
|
||||
}
|
||||
|
||||
return es.IlmForecastList(conf)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user