Skip to content

Commit

Permalink
feat(docs): add new metric docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderPoet committed Nov 16, 2023
1 parent 907d921 commit 4bee9b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ h.GET("/ping", func(c context.Context, ctx *app.RequestContext) {

Below is a table of HTTP server metric instruments.

| Name | Instrument Type | Unit | Unit | Description |
|-------------------------------|---------------------------------------------------|--------------|-------------------------------------------|------------------------------------------------------------------------------|
| `http.server.duration` | Histogram | milliseconds | `ms` | measures the duration inbound HTTP requests |
| Name | Instrument Type | Unit | Unit | Description |
|-----------------------------|-----------------|--------------|-----------|------------------------------------------------------------------------------|
| `http.server.duration` | Histogram | milliseconds | `ms`<br/> | measures the duration inbound HTTP requests |
| `http.server.request_count` | Counter | count | `count` | measures the incoming request count total |


#### Hertz Client
Expand All @@ -145,6 +146,7 @@ Below is a table of HTTP client metric instruments.
| Name | Instrument Type ([*](README.md#instrument-types)) | Unit | Unit ([UCUM](README.md#instrument-units)) | Description |
|-----------------------------|---------------------------------------------------|--------------|-------------------------------------------|----------------------------------------------------------|
| `http.client.duration` | Histogram | milliseconds | `ms` | measures the duration outbound HTTP requests |
| `http.client.request_count` | Counter | count | `count` | measures the client request count total |


### R.E.D
Expand All @@ -155,15 +157,15 @@ the number of requests, per second, you services are serving.

eg: QPS
```
sum(rate(http_server_duration_count{}[5m])) by (service_name, http_method)
sum(rate(http_server_request_count_total{}[5m])) by (service_name, http_method)
```

#### Errors
the number of failed requests per second.

eg: Error ratio
```
sum(rate(http_server_duration_count{status_code="Error"}[5m])) by (service_name, http_method) / sum(rate(http_server_duration_count{}[5m])) by (service_name, http_method)
sum(rate(http_server_request_count_total{status_code="Error"}[5m])) by (service_name, http_method) / sum(rate(http_server_request_count_total{}[5m])) by (service_name, http_method)
```

#### Duration
Expand All @@ -177,7 +179,7 @@ histogram_quantile(0.99, sum(rate(http_server_duration_bucket{}[5m])) by (le, se
### Service Topology Map
The `http.server.duration` will record the peer service and the current service dimension. Based on this dimension, we can aggregate the service topology map
```
sum(rate(http_server_duration_count{}[5m])) by (service_name, peer_service)
sum(rate(http_server_request_count_total{}[5m])) by (service_name, peer_service)
```

### Runtime Metrics
Expand Down
20 changes: 11 additions & 9 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,19 @@ h.GET("/ping", func(c context.Context, ctx *app.RequestContext) {

下表列出了 HTTP 服务的指标

| 名称 | Instrument Type | 单位 | 单位 | 描述 |
|-------------------------------|---------------------------------------------------|--------------|-------------------------------------------|------------------------------------------------------------------------------|
| `http.server.duration` | Histogram | milliseconds | `ms` | 测量入站 HTTP 请求的耗时 |
| 名称 | Instrument Type | 单位 | 单位 | 描述 |
|-----------------------------|---------------------------------------------------|--------------|-------------------------------------------|-----------------|
| `http.server.duration` | Histogram | milliseconds | `ms` | 测量入站 HTTP 请求的耗时 |
| `http.server.request_count` | Counter | count | `count` | 测量入站 HTTP 请求数 |

#### Hertz Client

下表列出了 HTTP 客户端指标

| 名称 | Instrument Type | 单位 | 单位 (UCUM) | 描述 |
|-----------------------------|---------------------------------------------------|--------------|-------------------------------------------|----------------------------------------------------------|
| `http.client.duration` | Histogram | milliseconds | `ms` | 测量出站 HTTP 请求的耗时 |
| 名称 | Instrument Type | 单位 | 单位 (UCUM) | 描述 |
|-----------------------------|---------------------------------------------------|--------------|-------------------------------------------|-----------------|
| `http.client.duration` | Histogram | milliseconds | `ms` | 测量出站 HTTP 请求的耗时 |
| `http.client.request_count` | Counter | count | `count` | 测量出站 HTTP 请求数 |


### R.E.D
Expand All @@ -163,7 +165,7 @@ R.E.D (Rate, Errors, Duration) 定义了架构中的每个微服务测量的三
例如: QPS(Queries Per Second)每秒查询率

```
sum(rate(http_server_duration_count{}[5m])) by (service_name, http_method)
sum(rate(http_server_request_count_total{}[5m])) by (service_name, http_method)
```

#### Errors
Expand All @@ -173,7 +175,7 @@ sum(rate(http_server_duration_count{}[5m])) by (service_name, http_method)
例如:错误率

```
sum(rate(http_server_duration_count{status_code="Error"}[5m])) by (service_name, http_method) / sum(rate(http_server_duration_count{}[5m])) by (service_name, http_method)
sum(rate(http_server_request_count_total{status_code="Error"}[5m])) by (service_name, http_method) / sum(rate(http_server_request_count_total{}[5m])) by (service_name, http_method)
```

#### Duration
Expand All @@ -190,7 +192,7 @@ histogram_quantile(0.99, sum(rate(http_server_duration_bucket{}[5m])) by (le, se

`http.server.duration`将记录对等服务和当前服务维度。基于这个维度,我们可以汇总生成服务拓扑图
```
sum(rate(http_server_duration_count{}[5m])) by (service_name, peer_service)
sum(rate(http_server_request_count_total{}[5m])) by (service_name, peer_service)
```

### Runtime Metrics
Expand Down

0 comments on commit 4bee9b7

Please sign in to comment.