diff --git a/TODO.md b/TODO.md index e8aef9f..ddca1ae 100644 --- a/TODO.md +++ b/TODO.md @@ -6,3 +6,18 @@ - add datastream support: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-stream +- Fix: cluster status word wrapping adds one \n to much: + +```console +Bad health shards_availability This cluster has 1 unavailable replica shard. + -> cause Elasticsearch isn't allowed to allocate some shards from these indices to any of the nodes in the + + cluster. + -> affected indices foo-t-log-logs-002947 + -> suggested action to fix Diagnose the issue by calling the allocation explain API for an index [GET + + _cluster/allocation/explain]. Choose a node to which you expect a shard to be allocated, find this + + node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from +``` + diff --git a/pkg/es/ilm.go b/pkg/es/ilm.go index 46562b8..b87597e 100644 --- a/pkg/es/ilm.go +++ b/pkg/es/ilm.go @@ -285,9 +285,11 @@ func IlmExplain(conf *cfg.Config, index string) error { info := "" - err = json.Unmarshal(ilm.StepInfo["reason"], &info) - if err != nil { - return fmt.Errorf("failed to unmarshal step info: %w", err) + if len(ilm.StepInfo["reason"]) > 0 { + err = json.Unmarshal(ilm.StepInfo["reason"], &info) + if err != nil { + return fmt.Errorf("failed to unmarshal step info: %w", err) + } } table.Entries = [][]any{ @@ -299,8 +301,11 @@ func IlmExplain(conf *cfg.Config, index string) error { {"phase", *ilm.Phase}, {"phase execution", ilmPhaseString(ilm.PhaseExecution.PhaseDefinition, false)}, {"step", *ilm.Step}, - {"failed step", *ilm.FailedStep}, - {"failed step retry count", ilm.FailedStepRetryCount}, + } + + if ilm.FailedStep != nil { + table.AddRow("failed step", *ilm.FailedStep) + table.AddRow("failed step retry count", ilm.FailedStepRetryCount) } if err := table.Print(); err != nil {