<p>To calculate disk space required by Prometheus v2.20 <strong>in bytes</strong>, use the query:</p>
<pre><code>retention_time_seconds *
rate(prometheus_tsdb_head_samples_appended_total[2h]) *
(rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[2h]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[2h]))
</code></pre>
<p>Where <code>retention_time_seconds</code> is the value you've configured for <code>--storage.tsdb.retention.time</code>, which defaults to <code>15d</code> = <code>1296000</code> seconds.</p>

CC BY-SA 4.0
2022-06-27T23:13:29.003Z
do you know we can exclude the space prometheus target itself would take? I have a target that samples every 1 minute. I think the storage required for that should be reasonably small, but when you add in prometheus target that is sampling every 5 seconds, the space required adds up. So I was wondering if there is a way to exclude prometheus target from space calculation ?
kaptan
CC BY-SA 4.0
2021-01-08T19:52:13.900Z
2021-01-08T19:52:13.900Z
Brandon
<p>I think your math may be off.  If you use the ~18600 number you found I get a very different result from 68TiB:</p>

<p><code>2,592,000 (seconds) * 18600 (samples/second) * 1.3 (bytes/sample) = 62,674,560,000 (bytes)</code>.  This is ~62.675 Gigabytes (divide the digital storage value by 1e+9
) and I'm guessing a more reasonable number for your infrastructure.</p>

CC BY-SA 4.0
2019-09-27T17:54:28.247Z
Absolutely correct - my math was off.  I thought I was going mad, just ended up being stupid. Thank you
MCoetzee
CC BY-SA 4.0
2021-01-08T19:53:38.683Z
Adding a separate answer that directly answers the question in the title, in case other folks are coming from Google and aren't concerned with the particular math errors that OP made
Brandon
CC BY-SA 4.0
2019-09-27T17:37:30.833Z
2019-09-27T17:37:30.833Z
Wesley Rolnick
<p>We are trying to calculate the storage requirements but is unable to find the values needed to do the calculation for our version of Prometheus (v2.2).</p>

<p><a href="https://prometheus.io/docs/prometheus/2.2/storage/" rel="noreferrer">Prometheus(v2.2) storage</a> documentation gives this simple formula:</p>

<pre><code>needed_disk_space = retention_time_seconds * ingested_samples_per_second * bytes_per_sample
</code></pre>

<ul>
<li><strong>retention_time_seconds</strong>: We took our retention time of 720 hours and converted to <code>2 592 000</code>seconds.</li>
<li><strong>bytes_per_sample</strong>: We used <code>rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[1d]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[1d])</code> based on the formula from <a href="https://www.robustperception.io/how-much-ram-does-prometheus-2-x-need-for-cardinality-and-ingestion" rel="noreferrer">this site</a>, except we did not have <code>prometheus_tsdb_compaction_chunk_size_bytes_sum</code> so used <code>prometheus_tsdb_compaction_chunk_size_sum</code> instead. This gives us ~<code>1.3</code>, which sounds about right.</li>
<li><p><strong>ingested_samples_per_second</strong>: We cannot find a way to get this value. We tried the following:</p>

<ul>
<li><p><a href="https://logz.io/blog/prometheus-monitoring/" rel="noreferrer">This site</a> suggest <code>prometheus_local_storage_chunk_ops_total</code>, but we do not have this metric.</p>

<blockquote>
  <p>Another useful metric to query and visualize is the prometheus_local_storage_chunk_ops_total metric that reports the per-second rate of all storage chunk operations taking place in Prometheus.</p>
</blockquote></li>
<li><p><a href="https://www.robustperception.io/how-much-disk-space-do-prometheus-blocks-use" rel="noreferrer">This</a> uses <code>rate(prometheus_tsdb_head_samples_appended_total[1h])</code>, but the result is ~<code>18600</code> suggesting <code>68TiB</code> storage.</p>

<blockquote>
  <p>Combined with rate(prometheus_tsdb_head_samples_appended_total[1h]) for the samples ingested per second, you should have a good idea of how much disk space you need given your retention window.</p>
</blockquote></li>
<li>As above, <a href="https://github.com/prometheus/tsdb/issues/123" rel="noreferrer">this issue</a> mentions <code>rate(tsdb_samples_appended_total[5m])</code>, but probably meant (or what we got working is) <code>rate(prometheus_tsdb_head_samples_appended_total[5m])</code>

<blockquote>
  <p>You can still get samples per second via rate(tsdb_samples_appended_total[5m]).</p>
</blockquote></li>
<li><a href="https://groups.google.com/forum/#!topic/prometheus-users/kq5azoNNKUs" rel="noreferrer">This</a> uses <code>prometheus_local_storage_ingested_samples_total</code>, but again, it is not available to us.

<blockquote>
  <p>sample rate = rate(prometheus_local_storage_ingested_samples_total{job="prometheus",instance="$Prometheus:9090"}[1m])</p>
</blockquote></li>
<li>Finally <a href="https://github.com/prometheus/prometheus/issues/1573" rel="noreferrer">this issue</a> also says to use <code>rate(prometheus_local_storage_ingested_samples_total[2m])</code>, and once again, it is not available to us.

<blockquote>
  <p>The other side is ingestion, which is way easier to reason with capacity-wise. You can find out how many samples your server is ingesting with this query:
  rate(prometheus_local_storage_ingested_samples_total[2m])</p>
</blockquote></li>
</ul></li>
</ul>

<p>Any assitance or nudge in the right direction would be much appreciated.</p>

<p><strong>>>> What worked in the end &lt;&lt;&lt;</strong></p>

<p>As was pointed out, our math was broken, so the below metrics worked for the calculation.</p>

<ul>
<li><strong>ingestion_samples_per_second</strong>: <code>rate(prometheus_tsdb_head_samples_appended_total[2h])</code></li>
<li><strong>bytes_per_sample</strong>: <code>rate(prometheus_tsdb_compaction_chunk_size_sum[2h]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[2h])</code></li>
</ul>

CC BY-SA 4.0
2020-10-07T07:06:30.387Z
For those of you using prometheus v2.20, the bytes per sample expression is slightly different:

rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[2h]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[2h])
Javier PR
<prometheus>
How to calculate disk space required by Prometheus v2.2?
MCoetzee
# How to calculate disk space required by Prometheus v2.2?

(Asked by: username_0 on 2019-09-27)

We are trying to calculate the storage requirements but is unable to find the values needed to do the calculation for our version of Prometheus (v2.2).
Prometheus(v2.2) storage documentation gives this simple formula:
needed_disk_space = retention_time_seconds * ingested_samples_per_second * bytes_per_sample


retention_time_seconds: We took our retention time of 720 hours and converted to 2 592 000seconds.
bytes_per_sample: We used rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[1d]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[1d]) based on the formula from this site, except we did not have prometheus_tsdb_compaction_chunk_size_bytes_sum so used prometheus_tsdb_compaction_chunk_size_sum instead. This gives us ~1.3, which sounds about right.
ingested_samples_per_second: We cannot find a way to get this value. We tried the following:

This site suggest prometheus_local_storage_chunk_ops_total, but we do not have this metric.

Another useful metric to query and visualize is the prometheus_local_storage_chunk_ops_total metric that reports the per-second rate of all storage chunk operations taking place in Prometheus.

This uses rate(prometheus_tsdb_head_samples_appended_total[1h]), but the result is ~18600 suggesting 68TiB storage.

Combined with rate(prometheus_tsdb_head_samples_appended_total[1h]) for the samples ingested per second, you should have a good idea of how much disk space you need given your retention window.

As above, this issue mentions rate(tsdb_samples_appended_total[5m]), but probably meant (or what we got working is) rate(prometheus_tsdb_head_samples_appended_total[5m])

You can still get samples per second via rate(tsdb_samples_appended_total[5m]).

This uses prometheus_local_storage_ingested_samples_total, but again, it is not available to us.


sample rate = rate(prometheus_local_storage_ingested_samples_total{job="prometheus",instance="$Prometheus:9090"}[1m])

Finally this issue also says to use rate(prometheus_local_storage_ingested_samples_total[2m]), and once again, it is not available to us.


The other side is ingestion, which is way easier to reason with capacity-wise. You can find out how many samples your server is ingesting with this query:
  rate(prometheus_local_storage_ingested_samples_total[2m])



Any assitance or nudge in the right direction would be much appreciated.
>>> What worked in the end <<<
As was pointed out, our math was broken, so the below metrics worked for the calculation.

ingestion_samples_per_second: rate(prometheus_tsdb_head_samples_appended_total[2h])
bytes_per_sample: rate(prometheus_tsdb_compaction_chunk_size_sum[2h]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[2h])

**Tags:** prometheus

> **Comments:**
> **username_1**: For those of you using prometheus v2.20, the bytes per sample expression is slightly different:  rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[2h]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[2h])  

---

## 2 answers

### Answer by username_4 on 2019-09-27. Score: 4 | Accepted answer

I think your math may be off. If you use the ~18600 number you found I get a very different result from 68TiB:

`2,592,000 (seconds) * 18600 (samples/second) * 1.3 (bytes/sample) = 62,674,560,000 (bytes)`. This is ~62.675 Gigabytes (divide the digital storage value by 1e+9
) and I'm guessing a more reasonable number for your infrastructure.

> **Comments:**
> **username_0**: Absolutely correct - my math was off.  I thought I was going mad, just ended up being stupid. Thank you  
> **username_2**: Adding a separate answer that directly answers the question in the title, in case other folks are coming from Google and aren't concerned with the particular math errors that OP made  

---

### Answer by username_2 on 2021-01-08. Score: 8

To calculate disk space required by Prometheus v2.20 in bytes, use the query:
retention_time_seconds *
rate(prometheus_tsdb_head_samples_appended_total[2h]) *
(rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[2h]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[2h]))

Where retention_time_seconds is the value you've configured for --storage.tsdb.retention.time, which defaults to 15d = 1296000 seconds.

> **Comments:**
> **username_3**: do you know we can exclude the space prometheus target itself would take? I have a target that samples every 1 minute. I think the storage required for that should be reasonably small, but when you add in prometheus target that is sampling every 5 seconds, the space required adds up. So I was wondering if there is a way to exclude prometheus target from space calculation ?  

---

