# How to shrink the Elasticsearch data directory?

**URL:** <https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634>\
**Category:** Elasticsearch\
**Created:** [July 16, 2019, 3:03am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634 "2019-07-16T03:03:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsandri](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jsandri](https://discuss.elastic.co/u/jsandri)\
**Post date:** [July 16, 2019, 3:03am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/1 "2019-07-16T03:03:35Z")

</div>

Hi 🙂  
I deploy an ELK and Filebeat system on Centos 7, use Curator to remove old indices from Kibana. But the size of the data directory keeps growing so I conclude that this directory stores old indices yet, even those I removed from Kibana. My question is: Is there a way to shrink this directory? More precisely is there a way to only keep data that I visualize on Kibana?

---

<div class="post-metadata">

**Author:** ![harshbajaj16](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshbajaj16/32/44970_2.png) [@harshbajaj16](https://discuss.elastic.co/u/harshbajaj16)\
**Post date:** [July 16, 2019, 4:17am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/2 "2019-07-16T04:17:47Z")

</div>

Hi @jsandri,

This is not true if you delete the index from ES it removes data and indices both. could you please tell me how you conclude this??

> [@](#):
>
> Curator to remove old indices from Kibana. But the size of the data directory keeps growing so I conclude that this directory stores old indices yet, even those I removed from Kibana.

You can shrik your index with the use of Shrink API in elasticsearch.

> [@](#):
>
> My question is: Is there a way to shrink this directory?

Please find link of Shrink API for you reference.

> **[Shrink index API | Elasticsearch Guide \[master\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html)**

Regards,  
Harsh Bajaj

---

<div class="post-metadata">

**Author:** ![jsandri](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jsandri](https://discuss.elastic.co/u/jsandri)\
**Post date:** [July 16, 2019, 6:13am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/3 "2019-07-16T06:13:41Z")

</div>

Thanks for your response  
I concluded this because thanks to Curator I keep 2 days old indices so technically the size of the data directory should keep approximately the same size. And you're right files are removed but the size of the directory keeps growing and I checked Curator does its job well and we have approximatively the same amount of logs every day.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 16, 2019, 6:28am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/4 "2019-07-16T06:28:28Z")

</div>

Hi @jsandri, this seems surprising. When you delete an index Elasticsearch should delete the associated data from disk quite soon afterwards.

Can you share some actual figures? How big is the data directory, and how are you measuring this? How does that compare to the sizes of the individual indices reported by `GET /_cat/indices?bytes=b&v`? What about the individual shard sizes reported by `GET /_cat/shards?bytes=b&v`? Can you share the outputs here?

You can see a complete picture of the disk usage with this command:

```nohighlight
GET /_stats?level=shards&filter_path=indices.*.uuid,indices.*.shards.*.store,indices.*.shards.*.translog.size_in_bytes,indices.*.shards.*.routing

```

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [July 16, 2019, 6:38am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/5 "2019-07-16T06:38:30Z")

</div>

I agree with @DavidTurner on this. What you are describing is very much outside normal behavior for Elasticsearch.

I want to know what your storage backend is. What kind of storage are you using? Spinning disks? SSDs? And what is the filesystem type?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 16, 2019, 7:08am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/6 "2019-07-16T07:08:34Z")

</div>

Can you verify how long you are keeping indices in the cluster through the\_cat/indices API?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 13, 2019, 7:08am UTC](https://discuss.elastic.co/t/how-to-shrink-the-elasticsearch-data-directory/190634/7 "2019-08-13T07:08:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
