Skip to content

Commit

Permalink
ADD data_model.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchuansheng committed Dec 13, 2018
1 parent 346ab3f commit f72c6c6
Show file tree
Hide file tree
Showing 12 changed files with 850 additions and 36 deletions.
41 changes: 41 additions & 0 deletions 2-concepts/data_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 数据模型

Prometheus 所有采集的监控数据均以指标(metric)的形式保存在内置的[时间序列](https://www.wikiwand.com/zh/%E6%99%82%E9%96%93%E5%BA%8F%E5%88%97)数据库当中(TSDB)。每一条时间序列由指标名称(Metrics Name)以及一组标签(Labels)唯一标识,每条时间序列按照时间的先后顺序存储一系列的样本值。除了存储时间序列数据外,Prometheus 还可以临时生成时间序列数据作为查询的返回结果。

## 指标名称和标签

每一条时间序列由指标名称(Metrics Name)以及一组标签(键值对)唯一标识。其中指标的名称(metric name)可以反映被监控样本的含义(例如,`http_requests_total` — 表示当前系统接收到的 HTTP 请求总量),指标名称只能由 ASCII 字符、数字、下划线以及冒号组成,同时必须匹配正则表达式 `[a-zA-Z_:][a-zA-Z0-9_:]*`

> **[info] 注意**
>
> 冒号用来表示用户自定义的记录规则,不能在 exporter 中或监控对象直接暴露的指标中使用冒号来定义指标名称。
通过使用标签,Prometheus 开启了强大的多维数据模型:对于相同的指标名称,通过不同标签列表的集合,会形成特定的度量维度实例(例如:所有包含度量名称为 `/api/tracks` 的 http 请求,打上 `method=POST` 的标签,就会形成具体的 http 请求)。该查询语言在这些指标和标签列表的基础上进行过滤和聚合。改变任何度量指标上的任何标签值(包括添加或删除指标),都会创建新的时间序列。

标签的名称只能由 ASCII 字符、数字以及下划线组成并满足正则表达式 `[a-zA-Z_][a-zA-Z0-9_]*`。其中以 `__` 作为前缀的标签,是系统保留的关键字,只能在系统内部使用。标签的值则可以包含任何 `Unicode` 编码的字符。

更多详细内容请参考 [指标和标签命名最佳实践](../practices/naming.html)

## 样本

在时间序列中的每一个点称为一个样本(sample),样本由以下三部分组成:

+ 指标(metric):指标名称和描述当前样本特征的 labelsets;
+ 时间戳(timestamp):一个精确到毫秒的时间戳;
+ 样本值(value): 一个 folat64 的浮点型数据表示当前样本的值。

This comment has been minimized.

Copy link
@albumcover

albumcover Aug 23, 2023

typo: folat64 -> float64


## 符号

表示一个度量指标和一组键值对标签,需要使用以下符号:

```bash
<metric name>{<label name>=<label value>, ...}
```

例如,指标名称为 `api_http_requests_total`,标签为 `method="POST"``handler="/messages"` 的时间序列可以表示为:

```bash
api_http_requests_total{method="POST", handler="/messages"}
```

这与 [OpenTSDB](http://opentsdb.net/) 中使用的符号相同。
9 changes: 6 additions & 3 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [第1节:Prometheus 简介](1-introduction/overview.md)

## 第二章:概念
- [第1节:数据模型](2-concepts/data_model.md)

## 第三章:Prometheus

Expand All @@ -26,8 +27,10 @@

## 第四章:可视化

## 第五章:其他操作
## 第五章:监控手段

## 第六章:告警
## 第六章:其他操作

## 第七章:最佳实践
## 第七章:告警

## 第八章:最佳实践
42 changes: 36 additions & 6 deletions _book/1-introduction/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">


<link rel="next" href="../2-concepts/data_model.html" />


<link rel="prev" href="../" />

Expand Down Expand Up @@ -184,6 +186,19 @@



<li class="chapter " data-level="3.1" data-path="../2-concepts/data_model.html">

<a href="../2-concepts/data_model.html">


第1节:数据模型

</a>



</li>




Expand Down Expand Up @@ -376,21 +391,28 @@



<li class="header">第五章:其他操作</li>
<li class="header">第五章:监控手段</li>






<li class="header">第六章:告警</li>
<li class="header">第六章:其他操作</li>






<li class="header">第七章:最佳实践</li>
<li class="header">第七章:告警</li>






<li class="header">第八章:最佳实践</li>



Expand Down Expand Up @@ -474,7 +496,7 @@ <h2 id="prometheus-&#x9002;&#x7528;&#x4E8E;&#x4EC0;&#x4E48;&#x573A;&#x666F;"><a
<h2 id="prometheus-&#x4E0D;&#x9002;&#x5408;&#x4EC0;&#x4E48;&#x573A;&#x666F;"><a name="prometheus-&#x4E0D;&#x9002;&#x5408;&#x4EC0;&#x4E48;&#x573A;&#x666F;" class="anchor-navigation-ex-anchor" href="#prometheus-&#x4E0D;&#x9002;&#x5408;&#x4EC0;&#x4E48;&#x573A;&#x666F;"><i class="fa fa-link" aria-hidden="true"></i></a>3. Prometheus &#x4E0D;&#x9002;&#x5408;&#x4EC0;&#x4E48;&#x573A;&#x666F;</h2>
<p>Prometheus &#x975E;&#x5E38;&#x91CD;&#x89C6;&#x53EF;&#x9760;&#x6027;&#xFF0C;&#x5373;&#x4F7F;&#x5728;&#x51FA;&#x73B0;&#x6545;&#x969C;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x968F;&#x65F6;&#x67E5;&#x770B;&#x6709;&#x5173;&#x7CFB;&#x7EDF;&#x7684;&#x53EF;&#x7528;&#x7EDF;&#x8BA1;&#x4FE1;&#x606F;&#x3002;&#x5982;&#x679C;&#x4F60;&#x9700;&#x8981;&#x767E;&#x5206;&#x4E4B;&#x767E;&#x7684;&#x51C6;&#x786E;&#x5EA6;&#xFF0C;&#x4F8B;&#x5982;&#x6309;&#x8BF7;&#x6C42;&#x6570;&#x91CF;&#x8BA1;&#x8D39;&#xFF0C;&#x90A3;&#x4E48; Prometheus &#x4E0D;&#x592A;&#x9002;&#x5408;&#x4F60;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x6536;&#x96C6;&#x7684;&#x6570;&#x636E;&#x53EF;&#x80FD;&#x4E0D;&#x591F;&#x8BE6;&#x7EC6;&#x5B8C;&#x6574;&#x3002;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F60;&#x6700;&#x597D;&#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x7CFB;&#x7EDF;&#x6765;&#x6536;&#x96C6;&#x548C;&#x5206;&#x6790;&#x6570;&#x636E;&#x4EE5;&#x8FDB;&#x884C;&#x8BA1;&#x8D39;&#xFF0C;&#x5E76;&#x4F7F;&#x7528; Prometheus &#x6765;&#x76D1;&#x63A7;&#x7CFB;&#x7EDF;&#x7684;&#x5176;&#x4F59;&#x90E8;&#x5206;&#x3002; </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; www.yangcs.net 2018 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification"> Updated at
2018-12-13 14:00:47
2018-12-13 14:05:59
</span></footer>

</section>
Expand Down Expand Up @@ -502,19 +524,23 @@ <h1 class="search-results-title">No results matching "<span class='search-query'



<a href="../" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 序言">
<a href="../" class="navigation navigation-prev " aria-label="Previous page: 序言">
<i class="fa fa-angle-left"></i>
</a>


<a href="../2-concepts/data_model.html" class="navigation navigation-next " aria-label="Next page: 第1节:数据模型">
<i class="fa fa-angle-right"></i>
</a>



</div>

<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"第1节:Prometheus 简介","level":"2.1","depth":1,"next":{"title":"第1节:初识 Prometheus","level":"4.1","depth":1,"ref":"","articles":[]},"previous":{"title":" 序言","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["splitter","todo","alerts","anchors","image-captions","tbfed-pagefooter@^0.0.1","github-buttons@2.1.0","-lunr","-search","search-plus","advanced-emoji","-sharing","sharing-plus","simple-page-toc","anchor-navigation-ex","theme-comscore","download-pdf-link","code","-highlight","prism","prism-themes","favicon-plus"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © www.yangcs.net 2018","modify_label":" Updated at ","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prism-themes/themes/prism-base16-ateliersulphurpool.light.css"]},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"todo":{},"splitter":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"sitemap-general":{"prefix":"https://www.yangcs.net/prometheus/"},"fontsettings":{"theme":"white","family":"sans","size":2},"favicon-plus":{"appleTouchIconPrecomposed152":"","favicon":"./favicon-96x96.png","output":"_book"},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"fa fa-hand-o-right","level2Icon":"fa fa-hand-o-right","level3Icon":"fa fa-hand-o-right","showLevelIcon":true},"mode":"float","multipleH1":false,"pageTop":{"level1Icon":"fa fa-hand-o-right","level2Icon":"fa fa-hand-o-right","level3Icon":"fa fa-hand-o-right","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"theme-comscore":{},"prism-themes":{},"alerts":{},"github-buttons":{"repo":"yangchuansheng/prometheus-handbook","types":["star"],"size":"small"},"download-pdf-link":{"label":"Download PDF","base":"https://www.gitbook.com/download/pdf/book/yangchuansheng/the-way-to-go","multilingual":false},"advanced-emoji":{"embedEmojis":false},"sharing":{"qq":false,"all":["facebook","google","twitter","weibo","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":true,"vk":false,"pocket":false,"google":true,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":true},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"search-plus":{},"image-captions":{"variable_name":"_pictures"}},"theme":"default","author":"杨传胜","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[]},"title":"Prometheus 中文文档","language":"zh-hans","links":{"sidebar":{"Ryan Yang":"https://www.yangcs.net"}},"gitbook":"*","description":"Prometheus 中文文档"},"file":{"path":"1-introduction/overview.md","mtime":"2018-12-13T06:00:47.730Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-12-13T06:01:08.985Z"},"basePath":"..","book":{"language":""}});
gitbook.page.hasChanged({"page":{"title":"第1节:Prometheus 简介","level":"2.1","depth":1,"next":{"title":"第1节:数据模型","level":"3.1","depth":1,"path":"2-concepts/data_model.md","ref":"2-concepts/data_model.md","articles":[]},"previous":{"title":" 序言","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["splitter","todo","alerts","anchors","image-captions","tbfed-pagefooter@^0.0.1","github-buttons@2.1.0","-lunr","-search","search-plus","advanced-emoji","-sharing","sharing-plus","simple-page-toc","anchor-navigation-ex","theme-comscore","download-pdf-link","code","-highlight","prism","prism-themes","favicon-plus","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © www.yangcs.net 2018","modify_label":" Updated at ","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prism-themes/themes/prism-base16-ateliersulphurpool.light.css"]},"livereload":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"todo":{},"splitter":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"code":{"copyButtons":true},"sitemap-general":{"prefix":"https://www.yangcs.net/prometheus/"},"fontsettings":{"theme":"white","family":"sans","size":2},"favicon-plus":{"appleTouchIconPrecomposed152":"","favicon":"./favicon-96x96.png","output":"_book"},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"fa fa-hand-o-right","level2Icon":"fa fa-hand-o-right","level3Icon":"fa fa-hand-o-right","showLevelIcon":true},"mode":"float","multipleH1":false,"pageTop":{"level1Icon":"fa fa-hand-o-right","level2Icon":"fa fa-hand-o-right","level3Icon":"fa fa-hand-o-right","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"theme-comscore":{},"prism-themes":{},"alerts":{},"github-buttons":{"repo":"yangchuansheng/prometheus-handbook","types":["star"],"size":"small"},"download-pdf-link":{"label":"Download PDF","base":"https://www.gitbook.com/download/pdf/book/yangchuansheng/the-way-to-go","multilingual":false},"advanced-emoji":{"embedEmojis":false},"sharing":{"qq":false,"all":["facebook","google","twitter","weibo","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":true,"vk":false,"pocket":false,"google":true,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":true},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"search-plus":{},"image-captions":{"variable_name":"_pictures"}},"theme":"default","author":"杨传胜","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[]},"title":"Prometheus 中文文档","language":"zh-hans","links":{"sidebar":{"Ryan Yang":"https://www.yangcs.net"}},"gitbook":"*","description":"Prometheus 中文文档"},"file":{"path":"1-introduction/overview.md","mtime":"2018-12-13T06:05:59.543Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-12-13T06:51:13.168Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
Expand Down Expand Up @@ -556,6 +582,10 @@ <h1 class="search-results-title">No results matching "<span class='search-query'



<script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>



<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>


Expand Down
Loading

0 comments on commit f72c6c6

Please sign in to comment.