Skip to content

1. Prometheus容量管理

对Prometheus的容量来进行评估

按照官方数据,每个样本指标平均占用存储空间为1-2 字节,我们通过下面的公式可对总容量进行粗略的计算:

needed_disk_space = retention_time_seconds * ingested_samples_per_second * bytes_per_sample

参数说明
retention_time_seconds为数据保留时间范围内的总时间数
ingested_samples_per_second为平均每秒获取的指标数量
bytes_per_sample每条样本数据占用的空间大小,此处取2 字节

ingested_samples_per_second的数量可以采用下面的PromQL表达式获取,该表达式会计算出最近5分钟平均每秒获取的样本数量

rate(prometheus_tsdb_head_samples_appended_total[5m])

假设系统平均每秒获取的指标数量为10万个,按照默认样本保留 15天计算,那么需要的空间至少为259G。

(3600*24*15)* 100000 * 2 ≈ 259G