show green and failed indices in status, rename red to failed in index ls

This commit is contained in:
2026-07-08 09:57:39 +02:00
parent 03cfeb4336
commit 82c6d2e7bb
2 changed files with 12 additions and 6 deletions

View File

@@ -75,10 +75,10 @@ func IndexList(conf *cfg.Config) *cli.Command {
Aliases: []string{"H"}, Aliases: []string{"H"},
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "reds", Name: "failed",
Usage: "include only red failed indicies", Usage: "include only red failed indicies",
Destination: &conf.Failed, Destination: &conf.Failed,
Aliases: []string{"r"}, Aliases: []string{"f"},
}, },
&cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "filter", Name: "filter",

View File

@@ -174,11 +174,16 @@ func ClusterStatus(conf *cfg.Config) error {
} }
// look for red indices, if any // look for red indices, if any
redindices := 0 failedIndices := 0
greenIndices := 0
for _, index := range *res.indices { for _, index := range *res.indices {
if *index.Health == "red" { switch {
redindices++ case *index.Health != "green":
failedIndices++
case !strings.HasPrefix(*index.Index, "."):
// don't count internal indices
greenIndices++
} }
} }
@@ -205,7 +210,8 @@ func ClusterStatus(conf *cfg.Config) error {
{"Unassigned Primary Shards", res.health.UnassignedPrimaryShards}, {"Unassigned Primary Shards", res.health.UnassignedPrimaryShards},
{"Pending Tasks", res.health.NumberOfPendingTasks}, {"Pending Tasks", res.health.NumberOfPendingTasks},
{"Nodes", res.health.NumberOfNodes}, {"Nodes", res.health.NumberOfNodes},
{"Red Indices", redindices}, {"Green Indices", greenIndices},
{"Failed Indices", failedIndices},
{"Long Running Tasks", longtasks}, {"Long Running Tasks", longtasks},
} }