# **Metric types**
<br />
## **Counter**
`Counter` 是一個累積指標,他代表一個單調遞增的計數器,其值只能增加或在重新啟動時重置為零。例如,您可以使用 counter 來表示已服務的請求數量,已完成任務數量,或錯誤的數量。
不要使用 counter 來表達可以減小的值。例如,不要對當前正在運行的進程數使用 counter,而是要使用 gauge。
Counters 的客戶端庫使用文檔:
* [Go](https://godoc.org/github.com/prometheus/client_golang/prometheus#Counter)
* [Java](https://github.com/prometheus/client_java/blob/master/simpleclient/src/main/java/io/prometheus/client/Counter.java)
* [Python](https://github.com/prometheus/client_python#counter)
* [Ruby](https://github.com/prometheus/client_ruby#counter)
## **Gauge**
`Gauge` 是一個代表可以任意上下波動的單個數值的指標。
Gauge 通常用于測量值,例如溫度、當前內存使用量,還用于可能上升和下降的計數,例如并發請求數。
Gauges 的客戶端庫使用文檔:
* [Go](https://godoc.org/github.com/prometheus/client_golang/prometheus#Gauge)
* [Java](https://github.com/prometheus/client_java/blob/master/simpleclient/src/main/java/io/prometheus/client/Gauge.java)
* [Python](https://github.com/prometheus/client_python#gauge)
* [Ruby](https://github.com/prometheus/client_ruby#gauge)
## **Histogram**
`Histogram 直方圖`對觀察值(通常是請求持續時間或響應大小)進行采樣,并將其計數在可配置的 buckets 中。它還提供所有觀察值的總和。
基本指標名稱為`<basename>`的 histogram 會在一次抓取中暴露多個時間序列。
* 觀察桶(observation buckets)的累積計數器,顯示為`<basename>_bucket{le="包含作用域的上限>"}`
* 所有觀察值的總和,顯示為 `<basename>_sum`
* 觀察到的事件計數,顯示為 `<basename>_count(與上面相同,i.e. <basename>_bucket{le="+Inf"})`
使用 [histogram_quantile()](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) 函數可以根據直方圖甚至是直方圖的聚合來計算分位數,histogram 也適用于計算 [Apdex score](https://en.wikipedia.org/wiki/Apdex)。當在 buckets 上操作時,記住 histogram 也是[累積](https://en.wikipedia.org/wiki/Histogram#Cumulative_histogram)的。有關 histograms 和 summaries 的詳細信息,可以參考[histograms and summaries](https://prometheus.io/docs/practices/histograms)。
Histograms 客戶端庫使用文檔:
* [Go](https://godoc.org/github.com/prometheus/client_golang/prometheus#Histogram)
* [Java](https://github.com/prometheus/client_java/blob/master/simpleclient/src/main/java/io/prometheus/client/Histogram.java)
* [Python](https://github.com/prometheus/client_python#histogram)
* [Ruby](https://github.com/prometheus/client_ruby#histogram)
## **Summary**
類似于 histogram,一個 summary 會采樣觀察值(通常是請求持續事件和響應大小)。盡管它還提供了觀測值的總數和所有觀測值的總和,但它可以計算滑動時間窗口內的可配置分位數。
基本指標名稱為 `<basename>` 的 summary 會在一次抓取指標期間顯示多個時間序列:
* 觀察到的事件 streaming φ 分位數(0≤φ≤1),顯示為 `<basename> {quantile =“ <φ>”}`
* 所有觀察值的總和,顯示為 `<basename> _sum`
* 已觀察到的事件計數,顯示為 `<basename> _count`
有關 φ 分位數的詳細說明,摘要用法以及與直方圖的差異,請參見 [histograms and summaries](https://prometheus.io/docs/practices/histograms)。
Summaries 客戶端庫使用文檔:
* [Go](https://godoc.org/github.com/prometheus/client_golang/prometheus#Summary)
* [Java](https://github.com/prometheus/client_java/blob/master/simpleclient/src/main/java/io/prometheus/client/Summary.java)
* [Python](https://github.com/prometheus/client_python#summary)
* [Ruby](https://github.com/prometheus/client_ruby#summary)
- 介紹(Introduction)
- 概覽(Overview)
- First steps
- 方案比較
- FAQ
- Roadmap
- Media
- 術語表(Glossary)
- 概念(Concepts)
- 數據模型(Data model)
- 指標類型(Metric types)
- 作業和實例(Jobs and instances)
- Prometheus
- Getting started
- 安裝
- 配置
- 配置
- 記錄規則(Recording Rules)
- 報警規則(Alerting Rules)
- 模版示例
- 模版參考
- Rules的單元測試
- Querying
- Basics
- Operators
- Functions
- Examples
- HTTP API
- 存儲(Storage)
- 聯邦(Federation)
- 管理API(Management API)
- 遷移(Migration)
- API穩定性
- 可視化(Virsualization)
- Instrumenting
- 客戶端庫
- 開發客戶端庫
- 推送metrics
- exporters & 集成
- 開發exporters
- 格式一覽(Exposition formats)
- Operating
- 安全
- 集成
- 報警(Alerting)
- 報警概覽
- Alertmanager
- 配置
- 客戶端
- 通知模版參考
- 通知模版樣例
- 管理API
- Best Practices
- Metric & label 名稱
- Instrumentation
- console & dashboard
- Histogram & summary
- 報警
- 記錄規則(Recording rules)
- 何時使用Pushgateway
- Remote write tuning
- Guides
- 使用cAdvisor監控Docker容器
- 使用基于文件的服務發現來發現抓取target
- Basic auth
- 使用node exporter來監控Linux宿主機metrics
- Instrumenting一個Go應用程序
- TLS加密