全インデックスをリストで取得する方法

こちらにやり方が書いてありました。

cat indices API | Elasticsearch Guide [8.0] | Elastic

次のHTTPリクエストで、取得できます。

GET /_cat/indices

// レスポンス
[
  {
    "health": "green",
    "status": "open",
    "index": ".geoip_databases",
    "uuid": "eHBNIY2oQJee3w52alIHNA",
    "pri": "1",
    "rep": "0",
    "docs.count": "39",
    "docs.deleted": "39",
    "store.size": "37.5mb",
    "pri.store.size": "37.5mb"
  },
  {
    "health": "yellow",
    "status": "open",
    "index": "demo-index",
    "uuid": "G8rwDsaRSpCMYayBfbfPdw",
    "pri": "1",
    "rep": "1",
    "docs.count": "2",
    "docs.deleted": "0",
    "store.size": "4.9kb",
    "pri.store.size": "4.9kb"
  },
  {
    "health": "green",
    "status": "open",
    "index": ".apm-custom-link",
// 以下略

ただこれだと、JSON形式で見づらいし、情報が多いです。

次のようにすると見やすくなります。インデックス名と、ヘルスの状態に絞り込み、YAML形式で取得できます。

GET /_cat/indices?h=index,health&format=yaml

// レスポンス
---
- index: ".geoip_databases"
  health: "green"
- index: "demo-index"
  health: "yellow"
- index: ".apm-custom-link"
  health: "green"
- index: ".kibana_task_manager_7.16.2_001"
  health: "green"
- index: ".kibana_7.16.2_001"
  health: "green"
- index: ".apm-agent-configuration"
  health: "green"
- index: "accesslog-2022"
  health: "yellow"
- index: ".tasks"
  health: "green"