ZBLOG

prometheus 的数据模型是什么,并分别举例子

Prometheus 数据模型是一个多维度的时间序列数据模型,其中包含了以下四个基本元素:

  1. Metric:指标名称,用于标识一组相关的时间序列数据。Metric 通常由名称和可选的标签(Labels)组成。

例如 http_requests_total 是一个 Metric,表示 HTTP 请求总数;cpu_usage_seconds_total{mode="user",instance="localhost:9100"} 是另一个 Metric,表示 CPU 使用时间。

  1. Time series:指定 Metric 的特定实例,表示在给定时间范围内某一时刻 Metric 的值。Time series 由 Metric 和其对应的 Label 值以及时间戳组成。

例如 http_requests_total{method="GET", handler="/api/v1/users"} 是 http_requests_total 的一个 time series,表示获取用户信息 API 的 GET 请求总数;cpu_usage_seconds_total{mode="system",instance="localhost:9100"} 是 cpu_usage_seconds_total 的另一个 time series,表示系统态 CPU 使用时间。

  1. Sample:表示一对 (timestamp, value),即某个 Metric 在某个时间点上的值。每个样本都对应一个唯一的 time series。

例如 (1628478127, 125) 表示在 Unix 时间戳为 1628478127(2021年8月9日10点35分27秒)时 http_requests_total{method=“GET”, handler=“/api/v1/users”} 的值为125;(1628478135, 0.4) 表示在 Unix 时间戳为 1628478135 时 cpu_usage_seconds_total{mode=“system”,instance=“localhost:9100”} 的值为0.4。

  1. Label:用于区分不同 time series 实例的标签键值对,例如 “method” 和 “handler” 是 http_requests_total 中的两个 label。

例如 http_requests_total{method="GET", handler="/api/v1/users"} 中的 method 和 handler 就是 label,它们可以被用来过滤、聚合或者分类 time series 数据。

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=2634

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?