提交 d1402543 编写于 作者: M menghaoranss

Revise document for metrics

上级 f11784db
......@@ -38,13 +38,3 @@ chapter = true
| *已知实现类* | *详细说明* |
| ------------------------- | ------------------------------------ |
| OpenTracingRootInvokeHook | 基于 OpenTracing 协议的请求调用入口追踪 |
## MetricsTrackerManager
| *SPI 名称* | *详细说明* |
| ------------------------------- | --------------------------- |
| MetricsTrackerManager | 度量指标追踪 |
| *已知实现类* | *详细说明* |
| ------------------------------- | ---------------------------- |
| PrometheusMetricsTrackerManager | 基于 Prometheus 的度量指标追踪 |
......@@ -39,12 +39,3 @@ chapter = true
| ------------------------- | ---------------------------------------------- |
| OpenTracingRootInvokeHook | Use OpenTracing protocol to trace request root |
## MetricsTrackerManager
| *SPI Name* | *Description* |
| ------------------------------- | ------------------------------- |
| MetricsTrackerManager | Metrics track manager |
| *Implementation Class* | *Description* |
| ------------------------------- | ------------------------------- |
| PrometheusMetricsTrackerManager | Use Prometheus to track metrics |
......@@ -21,7 +21,7 @@ chapter = true
同时,由于治理功能本身可以采用合适的第三方组件作为基础服务,需要我们抽象统一的接口,统一各种不同的组件的标准调用API,对接到治理功能模块。
最后对于可管理性和可观测性的要求,我们需要完善通过UI查询、操作和控制系统的功能,进一步完善对于 tracing 和 APM 的支持,实现 Metric 指标监控以及与 Prometheus、Grafana 的支持,实现实时监控
最后对于可管理性和可观测性的要求,我们需要完善通过UI查询、操作和控制系统的功能,进一步完善对于 tracing 和 APM 的支持。
## 目标
......@@ -34,4 +34,3 @@ chapter = true
对于可观测性,目标如下:
- 支持 OpenTracing/Skywalking 集成,实现调用链的跟踪;
- 实现 Metric 支持,对接 Prometheus、Grafana,实现监控指标的可视化展示。
\ No newline at end of file
......@@ -21,7 +21,7 @@ On the other hand, the unified coordination and the synchronization of policies
At the same time, since the governance function itself can use appropriate third-party components as basic services, we need to abstract a unified interface, unify the standard calling APIs of various components and dock to the governance function module.
Finally, for the requirements of manageability and observability, we need to improve the functions of querying, operating and controlling the system through the UI, further improving the support for tracing and APM, realizing the monitoring of Metric indicators and the support with Prometheus and Grafana for real-time monitoring.
Finally, for the requirements of manageability and observability, we need to improve the functions of querying, operating and controlling the system through the UI, further improving the support for tracing and APM.
## Goal
......@@ -33,5 +33,4 @@ For the governance function, the goals are as follows:
For observability, the goals are as follows:
- Support OpenTracing/Skywalking integration and realize call chain tracking;
- Implement Metric support, connect Prometheus and Grafana and realize visual display of monitoring indicators.
- Support OpenTracing/Skywalking integration and realize call chain tracking.
\ No newline at end of file
......@@ -10,4 +10,4 @@ chapter = true
本小节主要介绍 Apache ShardingSphere 可观察性的相关功能
* 应用性能监控集成
* 度量指标监控
......@@ -10,4 +10,3 @@ chapter = true
This chapter mainly introduces the features of the observability:
* APM Integration
* Metrics
+++
title = "度量指标监控"
weight = 2
+++
## 背景
`Metrics` 是一种评估系统在运行时的度量指标,通常一组度量指标可以帮助我们评估系统性能,为系统优化或业务策略给出相关的意见。
Apache ShardingSphere 旨在打造一款分布式数据库解决方案,而对于数据库来说,分析它的运行状态,连接数据,事务数,吞吐量等相关指标,
为数据库的调度,数据平滑迁移,分库分表等策略提供可视化的建议与帮助尤为重要。
## 方案
Apache ShardingSphere 遵循 `Metrics` 标准,定义了一套可插拔的 `SPI` 标准,它并不存储,收集,展现 `Metrics` 信息,
只是负责在程序中对 `Metrics` 进行埋点,目前默认的实现方案为: `Prometheus` 客户端API埋点,服务端通过
`http` 协议来定时抓取 `Metrics` 数据。
![流程图](https://shardingsphere.apache.org/document/current/img/control-panel/metrics/metrics.png)
## 指标
目前定义了4种类型的指标
* Counter : 计数器是一个累积度量,它表示单个单调递增的计数器,其值在重新启动时只能增加或重置为零。
* Gauge : 仪表盘是一种度量标准,它表示一个可以任意上下移动的数值。
* Histogram : 直方图对观察结果(通常是请求持续时间或响应大小等)进行采样,并按可配置的桶进行计数。它还提供了所有观测值的和。
* Summary : 摘要是类似于柱状图的观察结果(通常是请求持续时间和响应大小之类的内容)。虽然它还提供了观察值的总数和所有观察值的总和,但它计算了一个滑动时间窗口上的可配置分位数。
|名称 | 类型 |标签名称 | 说明 |
|:------------------------ |:--------------------- |:-------------|:-------------------- |
|request_total |Counter | 无 |收集 ShardingSphere 所有的请求 |
|sql_statement_count |Counter | sql_type |收集执行的 SQL 类型,比如 (SELECT,UPDATE,INSERT...)|
|channel_count |Gauge | 无 |收集 ShardingSphere-Proxy 的连接数 |
|requests_latency_histogram_millis |Histogram | 无 |收集执行所有请求的迟延时间(单位:ms) |
|sharding_datasource |Counter | datasource |收集执行 SQL 语句命中的分库 |
|sharding_table |Counter | table |收集执行 SQL 语句命中的分表 |
|transaction |Counter | status |收集所有的事务数量 |
## 使用
在 ShardingSphere-Proxy 的 server.yaml 文件中新增以下配置:
```yaml
metrics:
name: prometheus # 指定类型为 prometheus.
host: 127.0.0.1 # 指定 host,如果为空,则获取默认
port: 9190 # 指定 prometheus 服务端抓取 metrics 端口
enable : true # 配置为 true 代表开启,设置为 false 代表关闭 ,此字段不配置时候,默认开启.
```
用户自己搭建 `Prometheus` 服务,在 prometheus.yml 文件中新增如下配置:
```yaml
scrape_configs:
# The job name is added as a label `job=<job-name>` to any time series scraped from this config.
- job_name: 'shardingSphere-proxy'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9190']
```
## 面板
推荐使用 `Granfana`,用户可以自定义查询来个性化显示面板盘,后续我们会提供默认的面板盘配置。
+++
title = "Metrics"
weight = 2
+++
## Background
Metrics are measures of used to evaluate the performance of a system at run time.
Quantitative assessment can be used to evaluate the performance of a system and to give relevant opinions on system optimization or business strategy.
Apache ShardingSphere aims to build a distributed database solution.
For the database,it analyzes its running status,connection data,transaction number,throughput and other relevant indicators.
It is particularly important to provide visual advice and help for database scheduling,data smooth migration,sharding-database,sharding-table and other policies.
## Plan
Apache ShardingSphere follows the Metrics standard, which defines a pluggable SPI standard that does not store, collect, or display Metrics information,
It is only responsible for embedding Metrics in the program. Currently, the default implementation scheme is: Prometheus client API burial point, through which the service side passes
HTTP protocol to periodically grab Metrics data.
![the follow image](https://shardingsphere.apache.org/document/current/img/control-panel/metrics/metrics.png)
## Metrics indicators
Four types of metrics are currently defined.
* Counter : A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart.
* Gauge : A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
* 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.
* 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.
|name | type |labelName | description |
|:------------------------ |:--------------------- |:-------------|:-------------------- |
|request_total |Counter | |Collect all request of ShardingSphere-Proxy |
|sql_statement_count |Counter | sql_type |Collect all the types of SQL , example (SELECT,UPDATE,INSERT...)|
|channel_count |Gauge | |Collect all the connection number of ShardingSphere-Proxy |
|requests_latency_histogram_millis |Histogram | |Collect all the request latency time(ms) |
|sharding_datasource |Counter | datasource |Collect all the sql sharding datasource |
|sharding_table |Counter | table |Collect all the sql sharding table |
|transaction |Counter | status |Collect all the sql transaction
## Use
Add the following configuration to the server.yaml file of ShardingSphere-Proxy:
```yaml
metrics:
name: prometheus # The specified type is Prometheus.
host: 127.0.0.1 # Specify host and, if empty, get the default of ShardingSphere-Proxy.
port: 9190 # Specify the Prometheus server fetching metrics port.
enable : true # true for on and false for off ,if not config this, default value is true.
```
Users set up the Prometheus service by themselves, adding the following configuration in the prometheus.yml file:
```yaml
scrape_configs:
# The job name is added as a label `job=<job-name>` to any time series scraped from this config.
- job_name: 'shardingSphere-proxy'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9190']
```
## Dashboard
It is recommended to use Granfana. Users can customize the query to personalize the panel panel. Later we will provide the default panel panel configuration.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册