# Raw logs to data compression ratio

**URL:** <https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440>\
**Category:** Elasticsearch\
**Created:** [May 24, 2022, 2:43am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440 "2022-05-24T02:43:37Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 2:43am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/1 "2022-05-24T02:43:37Z")

</div>

Hi All,

I've been investigating some compression ratios of my live logs.

Two main catergories. Auditd logs and other logs like /var/log/messages etc.  
Both being ingested via filebeat 7.11 and running 7.11 cluster.

So what I've found is (on an average day, after dividing over a 7 day period).  
Auditd raw logs 3.97G  
Index size 13.27G  
Ratio about 3.34

Other raw logs 3.61G  
Index size 10G  
Ratio 2.77

These seems abnormally high ration from raw logs to index sizes. In many places, people talk about 30%-100% of raw logs size, I'm getting around 200% of raw log size.

Question:

1. Can the overhead be reduced. (Overhead being the additional data like filebeat version, source IP, source hostname etc etc.. )
2. I assume its already using deflate as a compression mode since its 7.11. Are there ways to improve compression ratios.

Regards,

Michael

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 24, 2022, 2:44am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/2 "2022-05-24T02:44:32Z")

</div>

What do the mappings for these look like, have you spent time working on them?

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 2:57am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/3 "2022-05-24T02:57:00Z")

</div>

Hi Mark,

I'm using standard filebeat index. The /var/log/messages goes into standard filebeat-7.\* index.  
The auditbeat uses the filebeat-auditd-7.\* otherwise the same filebeat standard.

Regards,

Michael

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 2:59am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/4 "2022-05-24T02:59:28Z")

</div>

I've sort of inherited support of this. I'm not really sure was any testing done to optimize it.

I understand you can choose to index or not index certain fields. Though I'm not sure if that will help. Its not like these logs have a huge range of field types.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 24, 2022, 3:02am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/5 "2022-05-24T03:02:24Z")

</div>

The default mappings are not super efficient, so you should really take a look at them.

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 3:19am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/6 "2022-05-24T03:19:42Z")

</div>

This implementation has been running for more than a year. Change index mappings, can it be done on live indexes? Or must the index be trashed and recreated?

Also setting best\_compression, can not be done on running indexes. Is it possible to be set, on next created index in sequence?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 24, 2022, 3:23am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/7 "2022-05-24T03:23:46Z")

</div>

Take a look at index templates (or composable templates at they are known now). Basically the idea is you set the template for the next set of indices that are created by the Beats, and they define the mappings and compression method.

Saves manually doing it.

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 3:47am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/8 "2022-05-24T03:47:57Z")

</div>

Okay I see what you mean.  
If I put "index.codec: best\_compression" in Elasticsearch.yml from the recommendation from [Part 2.0: The true story behind Elasticsearch storage requirements | Elastic Blog](https://www.elastic.co/blog/elasticsearch-storage-the-true-story-2.0)

Would that effect all newly created indexes?

Regards,

Michael

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 24, 2022, 3:49am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/9 "2022-05-24T03:49:54Z")

</div>

If it's in an appropriate template, yes.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 24, 2022, 4:47am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/10 "2022-05-24T04:47:37Z")

</div>

Also @michaelv Most people use Raw Logs to Primary storage when referring to Ratio, not total index size which includes replica,,, how many replicas do you have?

BTW that is a pretty old blog there is a slightly newer one [here](https://www.elastic.co/blog/filebeat-modiles-access-logs-and-elasticsearch-storage-requirements)

Here are some of the latest

> **[Tune for disk usage | Elasticsearch Guide \[8.2\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-disk-usage.html)**

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 5:17am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/11 "2022-05-24T05:17:35Z")

</div>

HI Stephen,

1 replica only. The blog post was given by ELK support staff.  
I'll read the newer blog post and see what its about.

Regards,

Michael

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 6:25am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/12 "2022-05-24T06:25:27Z")

</div>

One odd questin.

Using index.codec: best\_compression  
I thought 7.10 by default uses deflate as the compression. Why would you need to hardcode the best\_compression?

I've tried modifying the template, and yes the new index takes the best\_compression index.

Regards,

Michael

---

<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:** [May 24, 2022, 6:43am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/13 "2022-05-24T06:43:34Z")

</div>

> [@michaelv](#):
>
> I thought 7.10 by default uses deflate as the compression.

No, it does not.

> [@michaelv](#):
>
> Why would you need to hardcode the best\_compression?

Best compression is not the default as it adds a significant amount of overhead at indexing time.

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 24, 2022, 8:27am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/14 "2022-05-24T08:27:39Z")

</div>

Thanks Christian.. they are importing something like 50 million records per day.. not sure having a higher overhead is a good idea.

I've read doing warm nodes to do higher compression.. however, they only have 3 nodes. So that is not really an option as its the same node for the hot indicies.

---

<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:** [May 24, 2022, 9:19am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/15 "2022-05-24T09:19:34Z")

</div>

For lower data volumes the overhead of tbe best compression codec may be irrelevant.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 25, 2022, 8:07pm UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/16 "2022-05-25T20:07:58Z")

</div>

50M records / day

~600 Records / sec Avg

Certainly in the realm / value of best compression... I have use cases 10-20x+ using best compression

Basically it is a TCO and performance equation.

You might need to trade /add a couple % of CPU etc for greater storage savings.

I would say test and measure.

So what I was kinda saying before if your numbers are for total storage ... most people refer to primary storage when they speak of ratio

> Auditd raw logs 3.97G  
> Index size 13.27G \<!--- So Primary is about 6.6GB  
> Ratio about 3.34 \<!--- So Ratio is about 1.5
> 
> Other raw logs 3.61G  
> Index size 10G \<!--5GB  
> Ratio 2.77 \< 1.4 or so

Not that make your use case suddenly better / less overall storage but that is the math most folk mean when talking about.

That said perhaps tuning your mappings and best\_compression might make a meaningful difference

---

<div class="post-metadata">

**Author:** ![michaelv](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@michaelv](https://discuss.elastic.co/u/michaelv)\
**Post date:** [May 26, 2022, 9:23am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/17 "2022-05-26T09:23:20Z")

</div>

Thanks Stephen!

I'm planning to set one index at a time to have the best\_compression and observe how much additional cpu its using. The followed by the next largest index etc.. making sure I don't reach so much cpu utilisation that ingestion becomes too slow and I start getting a backlog

---

<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:** [June 23, 2022, 9:24am UTC](https://discuss.elastic.co/t/raw-logs-to-data-compression-ratio/305440/18 "2022-06-23T09:24:06Z")

</div>

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