spacewander commented on a change in pull request #5653:
URL: https://github.com/apache/apisix/pull/5653#discussion_r761585147



##########
File path: docs/en/latest/plugins/rocketmq-logger.md
##########
@@ -0,0 +1,234 @@
+---
+title: rocketmq-logger
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**Info**](#info)
+- [**How To Enable**](#how-to-enable)
+- [**Test Plugin**](#test-plugin)
+- [**Disable Plugin**](#disable-plugin)
+
+## Name
+
+`rocketmq-logger` is a plugin which provides the ability to push requests log 
data as JSON objects to your external rocketmq clusters.
+
+ In case if you did not receive the log data don't worry give it some time it 
will automatically send the logs after the timer function expires in our Batch 
Processor.
+
+For more info on Batch-Processor in Apache APISIX please refer.
+[Batch-Processor](../batch-processor.md)
+
+## Attributes
+
+| Name             | Type    | Requirement | Default        | Valid   | 
Description                                                                     
         |
+| ---------------- | ------- | ----------- | -------------- | ------- | 
----------------------------------------------------------------------------------------
 |
+| nameserver_list  | object  | required    |                |         | An 
array of rocketmq nameservers.                                                  
             |
+| topic            | string  | required    |                |         | Target 
 topic to push data.                                                            
  |
+| key              | string  | optional    |                |         | Keys 
of messages to send.                                               |
+| tag              | string  | optional   |                |         | Tags of 
messages to send.                           |
+| timeout          | integer | optional    | 3              | [1,...] | 
Timeout for the upstream to send data.                                          
         |
+| use_tls          | boolean | optional   | false          |         | Whether 
to open TLS                          |
+| access_key       | string  | optional   | ""             |         | access 
key for ACL, empty string means disable ACL.     |
+| secret_key       | string  | optional   | ""             |         | secret 
key for ACL.                         |
+| name             | string  | optional    | "rocketmq logger" |         | A  
unique identifier to identity the batch processor.                              
       |
+| meta_format      | enum    | optional    | "default"      | 
["default","origin"] | `default`: collect the request information with default 
JSON way. `origin`: collect the request information with original HTTP request. 
[example](#examples-of-meta_format)|
+| batch_max_size   | integer | optional    | 1000           | [1,...] | Set 
the maximum number of logs sent in each batch. When the number of logs reaches 
the set maximum, all logs will be automatically pushed to the `rocketmq` 
service.                         |
+| inactive_timeout | integer | optional    | 5              | [1,...] | The 
maximum time to refresh the buffer (in seconds). When the maximum refresh time 
is reached, all logs will be automatically pushed to the `rocketmq` service 
regardless of whether the number of logs in the buffer reaches the set maximum 
number. |
+| buffer_duration  | integer | optional    | 60             | [1,...] | 
Maximum age in seconds of the oldest entry in a batch before the batch must be 
processed.|
+| max_retry_count  | integer | optional    | 0              | [0,...] | 
Maximum number of retries before removing from the processing pipe line.        
         |
+| retry_delay      | integer | optional    | 1              | [0,...] | Number 
of seconds the process execution should be delayed if the execution fails.      
  |
+| include_req_body | boolean | optional    | false          | [false, true] | 
Whether to include the request body. false: indicates that the requested body 
is not included; true: indicates that the requested body is included. Note: if 
the request body is too big to be kept in the memory, it can't be logged due to 
Nginx's limitation. |
+| include_req_body_expr  | array  | optional    |          |         | When 
`include_req_body` is true, control the behavior based on the result of the 
[lua-resty-expr](https://github.com/api7/lua-resty-expr) expression. If 
present, only log the request body when the result is true. |
+| include_resp_body| boolean | optional    | false         | [false, true] | 
Whether to include the response body. The response body is included if and only 
if it is `true`. |
+| include_resp_body_expr  | array  | optional    |          |         | When 
`include_resp_body` is true, control the behavior based on the result of the 
[lua-resty-expr](https://github.com/api7/lua-resty-expr) expression. If 
present, only log the response body when the result is true. |
+
+### examples of meta_format
+
+- **default**:
+
+```json
+    {
+     "upstream": "127.0.0.1:1980",
+     "start_time": 1619414294760,
+     "client_ip": "127.0.0.1",
+     "service_id": "",
+     "route_id": "1",
+     "request": {
+       "querystring": {
+         "ab": "cd"
+       },
+       "size": 90,
+       "uri": "/hello?ab=cd",
+       "url": "http://localhost:1984/hello?ab=cd";,
+       "headers": {
+         "host": "localhost",
+         "content-length": "6",
+         "connection": "close"
+       },
+       "body": "abcdef",
+       "method": "GET"
+     },
+     "response": {
+       "headers": {
+         "connection": "close",
+         "content-type": "text/plain; charset=utf-8",
+         "date": "Mon, 26 Apr 2021 05:18:14 GMT",
+         "server": "APISIX/2.5",
+         "transfer-encoding": "chunked"
+       },
+       "size": 190,
+       "status": 200
+     },
+     "server": {
+       "hostname": "localhost",
+       "version": "2.5"
+     },
+     "latency": 0
+    }
+```
+
+- **origin**:
+
+```http
+    GET /hello?ab=cd HTTP/1.1
+    host: localhost
+    content-length: 6
+    connection: close
+
+    abcdef
+```
+
+## Info
+
+The `message` will write to the buffer first.
+It will send to the rocketmq server when the buffer exceed the 
`batch_max_size`,
+or every `buffer_duration` flush the buffer.
+
+In case of success, returns `true`.
+In case of errors, returns `nil` with a string describing the error (`buffer 
overflow`).
+
+### Sample Nameserver list
+
+Specify the nameservers of the external rocketmq servers as below sample.
+
+```json
+{
+    "127.0.0.1":9876,

Review comment:
       Need to update the nameserver format.

##########
File path: docs/zh/latest/plugins/rocketmq-logger.md
##########
@@ -0,0 +1,229 @@
+---
+title: rocketmq-logger
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**工作原理**](#工作原理)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`rocketmq-logger` 插件可以将接口请求日志以 JSON 的形式推送给外部 rocketmq 集群。
+
+如果在短时间内没有收到日志数据,请放心,它会在我们的批处理处理器中的计时器功能到期后自动发送日志。
+
+有关 Apache APISIX 中 Batch-Processor 的更多信息,请参考。
+[Batch-Processor](../batch-processor.md)
+
+## 属性
+
+| 名称             | 类型    | 必选项 | 默认值         | 有效值  | 描述                       
                      |
+| ---------------- | ------- | ------ | -------------- | ------- | 
------------------------------------------------ |
+| nameserver_list  | object  | 必须   |                |         | 要推送的 rocketmq 
的 nameserver 列表。        |
+| topic            | string  | 必须   |                |         | 要推送的 topic。   
                          |
+| key              | string  | 可选   |                |         | 发送消息的keys。    
                         |
+| tag              | string  | 可选   |                |         | 发送消息的tags。    
                         |
+| timeout          | integer | 可选   | 3              | [1,...] | 发送数据的超时时间。    
                      |
+| use_tls          | boolean | 可选   | false          |         | 是否开启TLS加密。    
                         |
+| access_key       | string  | 可选   | ""             |         | ACL认证的access 
key,空字符串表示不开启ACL。     |
+| secret_key       | string  | 可选   | ""             |         | ACL认证的secret 
key。                         |
+| name             | string  | 可选   | "rocketmq logger" |         | batch 
processor 的唯一标识。               |
+| meta_format      | enum    | 可选   | "default"      | ["default","origin"] | 
`default`:获取请求信息以默认的 JSON 编码方式。`origin`:获取请求信息以 HTTP 
原始请求方式。[具体示例](#meta_format-参考示例)|
+| batch_max_size   | integer | 可选   | 1000           | [1,...] | 
设置每批发送日志的最大条数,当日志条数达到设置的最大值时,会自动推送全部日志到 `rocketmq` 服务。|
+| inactive_timeout | integer | 可选   | 5              | [1,...] | 
刷新缓冲区的最大时间(以秒为单位),当达到最大的刷新时间时,无论缓冲区中的日志数量是否达到设置的最大条数,也会自动将全部日志推送到 `rocketmq` 
服务。 |
+| buffer_duration  | integer | 可选   | 60             | [1,...] | 
必须先处理批次中最旧条目的最长期限(以秒为单位)。 |
+| max_retry_count  | integer | 可选   | 0              | [0,...] | 
从处理管道中移除之前的最大重试次数。             |
+| retry_delay      | integer | 可选   | 1              | [0,...] | 
如果执行失败,则应延迟执行流程的秒数。           |
+| include_req_body | boolean | 可选   | false          | [false, true] | 是否包括请求 
body。false: 表示不包含请求的 body ;true: 表示包含请求的 body。注意:如果请求 body 没办法完全放在内存中,由于 Nginx 
的限制,我们没有办法把它记录下来。|
+| include_req_body_expr | array  | 可选    |           |         | 当 
`include_req_body` 开启时, 基于 
[lua-resty-expr](https://github.com/api7/lua-resty-expr) 
表达式的结果进行记录。如果该选项存在,只有在表达式为真的时候才会记录请求 body。 |
+| include_resp_body| boolean | 可选   | false          | [false, true] | 
是否包括响应体。包含响应体,当为`true`。 |
+| include_resp_body_expr | array  | 可选    |           |         | 是否采集响体, 
基于[lua-resty-expr](https://github.com/api7/lua-resty-expr)。 该选项需要开启 
`include_resp_body`|
+
+### meta_format 参考示例
+
+- **default**:
+
+```json
+    {
+     "upstream": "127.0.0.1:1980",
+     "start_time": 1619414294760,
+     "client_ip": "127.0.0.1",
+     "service_id": "",
+     "route_id": "1",
+     "request": {
+       "querystring": {
+         "ab": "cd"
+       },
+       "size": 90,
+       "uri": "/hello?ab=cd",
+       "url": "http://localhost:1984/hello?ab=cd";,
+       "headers": {
+         "host": "localhost",
+         "content-length": "6",
+         "connection": "close"
+       },
+       "body": "abcdef",
+       "method": "GET"
+     },
+     "response": {
+       "headers": {
+         "connection": "close",
+         "content-type": "text/plain; charset=utf-8",
+         "date": "Mon, 26 Apr 2021 05:18:14 GMT",
+         "server": "APISIX/2.5",
+         "transfer-encoding": "chunked"
+       },
+       "size": 190,
+       "status": 200
+     },
+     "server": {
+       "hostname": "localhost",
+       "version": "2.5"
+     },
+     "latency": 0
+    }
+```
+
+- **origin**:
+
+```http
+    GET /hello?ab=cd HTTP/1.1
+    host: localhost
+    content-length: 6
+    connection: close
+
+    abcdef
+```
+
+## 工作原理
+
+消息将首先写入缓冲区。
+当缓冲区超过 `batch_max_size` 时,它将发送到 rocketmq 服务器,
+或每个 `buffer_duration` 刷新缓冲区。
+
+如果成功,则返回 `true`。
+如果出现错误,则返回 `nil`,并带有描述错误的字符串(`buffer overflow`)。
+
+### Nameserver 列表
+
+配置多个nameserver地址如下:
+
+```json
+{
+    "127.0.0.1":9876,

Review comment:
       Ditto




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to