Prometheus: The Unicorn in Metrics

Image for post
Image for post

Overview

Key Functions:

Core Components:

Advantages and Disadvantages:

Data Model

Overall Design Concept

Image for post
Image for post

PTSDB Overview

Core Data Structure and Storage Format

Image for post
Image for post
Image for post
Image for post

Write Ahead Log

Image for post
Image for post

Metadata File

Image for post
Image for post

Index

Image for post
Image for post

Chunks

Image for post
Image for post

Tombstones

Image for post
Image for post

Query PromQL

http_requests_total
select * from http_requests_total where timestamp between xxxx and xxxx
http_requests_total{code="200", handler="query"}
select * from http_requests_total where code="200" and handler="query" and timestamp between xxxx and xxxx
http_requests_total{code~="20"}
select * from http_requests_total where code like "%20%" and timestamp between xxxx and xxxx
http_requests_total > 100
select * from http_requests_total where value > 100 and timestamp between xxxx and xxxx
http_requests_total[5m]
select * from http_requests_total where timestamp between xxxx-5m and xxxx
count(http_requests_total)
select count(*) from http_requests_total where timestamp between xxxx and xxxx
sum(http_requests_total)
select sum(value) from http_requests_total where timestamp between xxxx and xxxx
topk(3, http_requests_total)
select * from http_requests_total where timestamp between xxxx and xxxx order by value desc limit 3
irate(http_requests_total[5m])
select code, handler, instance, job, method, sum(value)/300 AS value from http_requests_total where timestamp between xxxx and xxxx group by code, handler, instance, job, method;

Key Technical Points of PTSDB

Solve the Disorder

Memory Management

Compaction

Snapshot

PTSDB Best Practices

needed_disk_space = retention_time_seconds * ingested_samples_per_second * bytes_per_sample

Challenges for PTSDB

Summary

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store