Skip to content
gqlxj1987's Blog
Go back

TSDB from Scratch

Edit page

原文链接

Time series data

Each data point is a tuple of a timestamp and a value

A 64 bit float turns out to be a good representation for counter as well as gauge values, so we go with that. (时间戳?)

定义好相应的label部分

Vertical and Horizontal

series
  ^   
  │   . . . . . . . . . . . . . . . . .   . . . . .   {__name__="request_total", method="GET"}
  │     . . . . . . . . . . . . . . . . . . . . . .   {__name__="request_total", method="POST"}
  │         . . . . . . .
  │       . . .     . . . . . . . . . . . . . . . .                  ... 
  │     . . . . . . . . . . . . . . . . .   . . . .   
  │     . . . . . . . . . .   . . . . . . . . . . .   {__name__="errors_total", method="POST"}
  │           . . .   . . . . . . . . .   . . . . .   {__name__="errors_total", method="GET"}
  │         . . . . . . . . .       . . . . .
  │       . . .     . . . . . . . . . . . . . . . .                  ... 
  │     . . . . . . . . . . . . . . . .   . . . . 
  v
    <-------------------- time --------------------->

关于写放大的问题?

解决方案:

$ tree ./data
./data
├── b-000001
   ├── chunks
   ├── 000001
   ├── 000002
   └── 000003
   ├── index
   └── meta.json
├── b-000004
   ├── chunks
   └── 000001
   ├── index
   └── meta.json
├── b-000005
   ├── chunks
   └── 000001
   ├── index
   └── meta.json
└── b-000006
    ├── meta.json
    └── wal
        ├── 000001
        ├── 000002
        └── 000003

Queried data can be rather aggressively cached in memory, yet under memory pressure the pages will be evicted. If the machine has unused memory, Prometheus will now happily cache the entire database, yet will immediately return it once another application needs it.


Edit page
Share this post on:

Previous Post
LXD tips
Next Post
Golang Distributed Data Store