惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
B
Blog
S
SegmentFault 最新的问题
Vercel News
Vercel News
博客园 - 聂微东
宝玉的分享
宝玉的分享
C
Check Point Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
V
V2EX
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
博客园 - 司徒正美
博客园_首页
Last Week in AI
Last Week in AI
博客园 - 叶小钗
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
F
Fortinet All Blogs
腾讯CDC
J
Java Code Geeks

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
如何估算 Prometheus 的本地存储和内存消耗
微信公众号 · 2022-11-02 · via 陈少文的网站

Please enable Javascript to view the contents

1. 本地存储容量

所需磁盘大小(GB) = 数据保留时长 _ 每秒获取指标数量 _ 指标数据大小 / 1024 / 1024 / 1024

其中

  • 每秒获取指标数量 rate(prometheus_tsdb_head_samples_appended_total[1d])
  • 一个小时内样本的平均大小 rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[1d])/rate(prometheus_tsdb_compaction_chunk_samples_sum[1d])

一天(86400 秒)的磁盘消耗,可以在 Prometheus 中直接查询:

86400 * (rate(prometheus_tsdb_head_samples_appended_total[1d]) * (rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[1d]) / rate(prometheus_tsdb_compaction_chunk_samples_sum[1d]))) / 1024 /1024 / 1024

例如,返回 {instance="localhost:9090", job="prometheus"} 4.437027408140867,那么表示 localhost:9090 实例每天需要消耗 4.437 GB 的存储空间。同时,在实例中,有不少于 3 个 wal 文件用于存储原始数据,每个 128 MB。

2. 内存消耗

内存消耗 = Prometheus Server 自身的内存消耗 + 数据块 block 内存消耗 + 抓取指标的内存消耗 + 查询带来的内存消耗

  • Prometheus Server 自身的内存消耗

在刚安装好的多节点高可用集群上,Prometheus Server 的内存消耗为 500 MB 左右。

  • 数据块 block 内存消耗

主要和以下参数相关

- 每秒获取指标数量 rate(prometheus_tsdb_head_samples_appended_total[1d])
- 每个指标的平均标签数
- 不同的标签 Pair 总数
- 每个标签 Pair 平均大小
- 数据块 block 落盘周期
  • 抓取指标的内存消耗

主要和以下参数相关

- 每秒获取指标数量 rate(prometheus_tsdb_head_samples_appended_total[1d])
- 一个小时内样本的平均大小
- 采集间隔,通常是 15s

在页面 https://www.robustperception.io/how-much-ram-does-prometheus-2-x-need-for-cardinality-and-ingestion/ 可以估算上面两部分。

  • 查询带来的内存消耗

当查询的数据不在内存时,Prometheus 会加载硬盘数据到内存,会有额外的内存消耗。

在生产中,通过 avg(container_memory_working_set_bytes{image!="", container="prometheus-server"}) / 1024 /1024 查询的 40 多个集群的平均内存消耗在 953 MB,每个集群平均个 300 Pod。


微信公众号