Prometheus Storage
On average, Prometheus uses only around 1-2 bytes per sample. Thus, to plan the capacity of a Prometheus server, you can use the rough formula:
|
|
Concepts
- chunks this data together in chunks of constant size (
1024 bytes
) - keeps all the currently used (incomplete) chunks in memory
- batch up write operations to store chunks on disk
Optimize
Memory Options
storage.local.memory-chunks
how many chunks can Prometheus keep in memory. Remember, it’s the number of chunks, not the size in bytes.
Suggested value:.
/ 1024 / 6
storage.local.max-chunks-to-persist
how many chunks can be waiting to be written to the disk.
Suggested value:memory-chunks / 2
The rushed mode
When the number of chunks in memory, waiting to be persisted to disk, grows too much, Prometheus entersthe rushed mode
and speed up persisting chunks.
Prometheus calculate an urgency score, as the number of chunks waiting for persistence in relation to
max-chunks-to-persist
and on how much the number of chunks in memory exceeds the memory-chunks
.- urgency_score > 0.8: Enter Rushed Mode
- urgency_score < 0.7: Leave Rushed Mode
Snapshot
Snapshot API
Prometheus V2.0 提供了snapshot机制用于TSDB Backend数据备份, 创建快照API开启方式:--web.enable-admin-api
|
|
Data Directory
|
|
Snapshot Directory
|
|
meta.json
|
|
- maxTime - minTime = storage.tsdb.min-block-duration (default: 2h)
- meta.json 文件存储了 series 起止时间 / metircs 数量 / block 目录名称;
- 每个snapshot 由一个或多个 Chunk Block 组成, 这些Block 共同存储了Prometheus TSDB 的全量数据;
- Chunk Block 生成的数量由 storage.tsdb.min-block-duration 和 storage.tsdb.max-block-duration 控制;
|
|
Prometheus Version: 1.7.0
1 time="2017-11-20T03:58:23+08:00" level=error msg="Storage needs throttling. Scrapes and rule evaluations will be skipped." chunksToPersist=92938 memoryChunks=493334 source="storage.go:1007" urgencyScore=1
Refers
- KubeCon 2017 - Prometheus Takeaways
- How much RAM does my Prometheus need for ingestion?
- Writing a Time Series Database from Scratch
- Continuous Improvement in Monitoring with Prometheus 2.0
- 剖析Prometheus的内部存储机制
- LevelDB 实现分析
Research
- Prometheus WAL Log
- Chunk Data
- Snapshot
扫一扫,分享到微信
Comments
Post a Comment
https://gengwg.blogspot.com/