From 0122009774fc9513cefd06fd13c61e62acf0ce99 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Wed, 6 May 2026 13:10:02 +0200 Subject: [PATCH] add es version to status output --- TODO.md | 2 +- pkg/es/cluster.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index f3d13ff..c9c2364 100644 --- a/TODO.md +++ b/TODO.md @@ -4,4 +4,4 @@ - Fix index names custom completion - add cluster default which would add a flag to the config, so that no -C is needed subsequently - add `cluster stats` from `/_cluster/stats` like mem, procs, open files, num indices, shards etc -- add version[s] to `cluster status` + or add these to `cluster status`, maybe add a `--stats` to include stats there? diff --git a/pkg/es/cluster.go b/pkg/es/cluster.go index ed43483..a0c94f7 100644 --- a/pkg/es/cluster.go +++ b/pkg/es/cluster.go @@ -124,16 +124,25 @@ func ClusterStatus(conf *cfg.Config) error { Header("accept", "application/json"). Do(context.Background()) if err != nil { - return fmt.Errorf("failed to getcluster health: %s", err) + return fmt.Errorf("failed to get cluster health: %s", err) } slog.Debug("ES result", "cluster health", res) + info, err := es.Info(). + Header("content-type", "application/json"). + Header("accept", "application/json"). + Do(context.Background()) + if err != nil { + return fmt.Errorf("failed to get cluster info: %s", err) + } + table := NewTable(2, 5) table.Addheaders(cluster, "status") table.entries = [][]string{ {"Cluster Name", Colorize(*&res.Status.Name, res.ClusterName)}, + {"ES Version", fmt.Sprintf("%s", info.Version.Int)}, {"Active Shards", fmt.Sprintf("%d", res.ActiveShards)}, {"Active Primary Shards", fmt.Sprintf("%d", res.ActivePrimaryShards)}, {"Indicies", fmt.Sprintf("%d", len(res.Indices))},