翻譯 原文鏈接
Prometheus客戶端庫提供了四種核心metric類型。這些類型目前只在客戶端庫(客戶端可以根據(jù)不同的數(shù)據(jù)類型調(diào)用不同的API借口)和在線協(xié)議中有區(qū)分,實際在Prometheus并沒有充分利用這些數(shù)據(jù)類型,而是簡單的把這些類型扁平為無類型的時間序列。不過,將來我們正在努力改變這一現(xiàn)狀。
Counter類型
Counter類型代表一類單調(diào)遞增的metrics。比如:服務(wù)的請求數(shù)、已完成的任務(wù)數(shù),錯誤發(fā)生的次數(shù)等。Counter類型不應(yīng)該用于非單調(diào)遞增的數(shù)據(jù),比如:當(dāng)前運行的goroutines數(shù)目(應(yīng)該用Gauge類型)。
Client library usage documentation for counters:
Gauge類型
Gauge類型代表一類數(shù)據(jù)可以任意變化的metrics。Gauge類型一般用于像溫度或者內(nèi)存使用率這種數(shù)據(jù)(任意上下變化),當(dāng)然也用于表示可以上下變化的"總數(shù)",比如:當(dāng)前運行的goroutines總數(shù)。
Client library usage documentation for gauges:
Histogram類型
A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.
A histogram with a base metric name of <basename> exposes multiple time series during a scrape:
- cumulative counters for the observation buckets, exposed as
<basename>_bucket{le="<upper inclusive bound>"} - the total sum of all observed values, exposed as
<basename>_sum - the count of events that have been observed, exposed as
<basename>_count(identical to<basename>_bucket{le="+Inf"}above)
Use the histogram_quantile() function to calculate quantiles from histograms or even aggregations of histograms. A histogram is also suitable to calculate an Apdex score. When operating on buckets, remember that the histogram is cumulative. See histograms and summaries for details of histogram usage and differences to summaries.
Client library usage documentation for histograms:
Summary類型
Similar to a histogram, a summary samples observations (usually things like request durations and response sizes). While it also provides a total count of observations and a sum of all observed values, it calculates configurable quantiles over a sliding time window.
A summary with a base metric name of <basename> exposes multiple time series during a scrape:
- streaming φ-quantiles (0 ≤ φ ≤ 1) of observed events, exposed as
<basename>{quantile="<φ>"} - the total sum of all observed values, exposed as
<basename>_sum - the count of events that have been observed, exposed as
<basename>_count
See histograms and summaries for detailed explanations of φ-quantiles, summary usage, and differences to histograms.
Client library usage documentation for summaries: