ElasticSearch find disk space usage

The Elasticsearch way to do this would be to use _cat/shards and look at the store column:

curl -XGET "http://localhost:9200/_cat/shards?v"

index              shard prirep state     docs   store ip            node
myindex_2014_12_19 2     r      STARTED  76661 415.6mb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 2     p      STARTED  76661 417.3mb 192.168.1.2 Frederick Slade
myindex_2014_12_19 2     r      STARTED  76661 416.9mb 192.168.1.3 Maverick
myindex_2014_12_19 0     r      STARTED  76984 525.9mb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 0     r      STARTED  76984   527mb 192.168.1.2 Frederick Slade
myindex_2014_12_19 0     p      STARTED  76984   526mb 192.168.1.3 Maverick
myindex_2014_12_19 3     r      STARTED    163 208.5kb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 3     p      STARTED    163 191.4kb 192.168.1.2 Frederick Slade
myindex_2014_12_19 3     r      STARTED    163 181.6kb 192.168.1.3 Maverick
myindex_2014_12_19 1     p      STARTED 424923   2.1gb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 1     r      STARTED 424923   2.1gb 192.168.1.2 Frederick Slade
myindex_2014_12_19 1     r      STARTED 424923   2.1gb 192.168.1.3 Maverick
myindex_2014_12_19 4     r      STARTED  81020 435.9mb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 4     p      STARTED  81020 437.8mb 192.168.1.2 Frederick Slade
myindex_2014_12_19 4     r      STARTED  81020 437.8mb 192.168.1.3 Maverick

Otherwise in Linux to view the space by folder use:

du -hs /myelasticsearch/data/folder

or to view the space by filesystem:

df -h 

To view the overall disk usage/available space on ES cluster you can use the following command:

curl -XGET 'localhost:9200/_cat/allocation?v&pretty'

Hope this helps.


In case you don't need per-shard statistics returned by /_cat/shards you can use

curl -XGET 'http://localhost:9200/_cat/allocation?v'

to get used and available disk space for each node.


you can use the nodes stats rest API
see: https://www.elastic.co/guide/en/elasticsearch/reference/1.6/cluster-nodes-stats.html

make a request for the fs stats like so: http://:9200/_nodes/stats/fs?pretty=1

and you will see:

{
  "cluster_name" : "<cluster>",
  "nodes" : {
    "pEO34wutR7qk3Ix8N7MgyA" : {
      "timestamp" : 1438880525206,
      "name" : "<name>",
      "transport_address" : "inet[/10.128.37.111:9300]",
      "host" : "<host>",
      "ip" : [ "inet[/10.128.37.111:9300]", "NONE" ],
      "fs" : {
        "timestamp" : 1438880525206,
        "total" : {
          "total_in_bytes" : 363667091456,
          "free_in_bytes" : 185081352192,
          "available_in_bytes" : 166608117760,
          "disk_reads" : 154891,
          "disk_writes" : 482628039,
          "disk_io_op" : 482782930,
          "disk_read_size_in_bytes" : 6070391808,
          "disk_write_size_in_bytes" : 1989713248256,
          "disk_io_size_in_bytes" : 1995783640064,
          "disk_queue" : "0",
          "disk_service_time" : "0"
        },
        "data" : [ {
          "path" : "/data1/elasticsearch/data/<cluster>/nodes/0",
          "mount" : "/data1",
          "dev" : "/dev/sda4",
          "total_in_bytes" : 363667091456,
          "free_in_bytes" : 185081352192,
          "available_in_bytes" : 166608117760,
          "disk_reads" : 154891,
          "disk_writes" : 482628039,
          "disk_io_op" : 482782930,
          "disk_read_size_in_bytes" : 6070391808,
          "disk_write_size_in_bytes" : 1989713248256,
          "disk_io_size_in_bytes" : 1995783640064,
          "disk_queue" : "0",
          "disk_service_time" : "0"
        } ]
      }
    }
  }
}

the space for the data drive is listed:

"total" : {
    "total_in_bytes" : 363667091456,
    "free_in_bytes" : 185081352192,
    "available_in_bytes" : 166608117760,