Skip to content

elasticsearch get-shards

Get detailed view of what nodes contain which shards

Description

Get detailed view of what nodes contain which shards along with info whether it’s a primary or replica, the number of docs, the bytes it takes on disk, and the node where it’s located.

Synopsis

elasticsearch get-shards
    [--site <site>]
    [--cluster <cluster>]
    [--target <target>]
    [--filter_path <filter_path>]
    [--sort <sort>]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

cluster - (string)

     Name of elastic search cluster
     Example: --cluster "elastic-default"
     Default: elastic-default      Attributes: optional

target - (string)

     List of data streams, indices, and index aliases used to limit the request
     Example: --target "students or _all"
     Default: _all      Attributes: optional, multiple allowed

filter_path - (string)

     Path in the response. Filters and returns only parts of response matching this path
     Example: --filter_path "index.mappings.properties.*"
     Default: _None_      Attributes: optional, multiple allowed

sort - (string)

     Column names or column aliases used to sort the response.
     Example: --sort "index,health"
     Default: index      Attributes: optional, multiple allowed

Examples

Input:

x = ! elasticsearch get-shards --cluster "elastic-1" --target "test" --target "class"
Output:
[
  {
    "index": "class",
    "shard": "1",
    "prirep": "p",
    "state": "STARTED",
    "docs": "0",
    "store": "208b",
    "ip": "127.0.0.1",
    "node": "beehyv-H81M-S"
  },
  {
    "index": "class",
    "shard": "1",
    "prirep": "r",
    "state": "UNASSIGNED",
    "docs": null,
    "store": null,
    "ip": null,
    "node": null
  },
  {
    "index": "class",
    "shard": "0",
    "prirep": "p",
    "state": "STARTED",
    "docs": "0",
    "store": "208b",
    "ip": "127.0.0.1",
    "node": "beehyv-H81M-S"
  },
  {
    "index": "class",
    "shard": "0",
    "prirep": "r",
    "state": "UNASSIGNED",
    "docs": null,
    "store": null,
    "ip": null,
    "node": null
  },
  {
    "index": "test",
    "shard": "0",
    "prirep": "p",
    "state": "STARTED",
    "docs": "0",
    "store": "230b",
    "ip": "127.0.0.1",
    "node": "beehyv-H81M-S"
  },
  {
    "index": "test",
    "shard": "0",
    "prirep": "r",
    "state": "UNASSIGNED",
    "docs": null,
    "store": null,
    "ip": null,
    "node": null
  }
]

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "elasticsearch"
Service Instance cluster
Namespace
Object Type "index"
Object ID target

Please see Access Control for details.