This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shenyu-website.git


The following commit(s) were added to refs/heads/main by this push:
     new 793c500b0b doc plugin-logging-rabbitmq:add config doc. (#1045)
793c500b0b is described below

commit 793c500b0bb2946fffaf6c968e6c8e9374213e92
Author: 李海峰 <[email protected]>
AuthorDate: Wed Dec 4 15:55:48 2024 +0800

    doc plugin-logging-rabbitmq:add config doc. (#1045)
---
 .../observability/logging-rabbitmq.md              | 181 +++++++++++++++++++++
 .../observability/logging-rabbitmq.md              | 175 ++++++++++++++++++++
 .../logging/logging-rabbitmq/call-service.png      | Bin 0 -> 26557 bytes
 .../logging/logging-rabbitmq/log-rule-en.jpg       | Bin 0 -> 206682 bytes
 .../logging/logging-rabbitmq/log-rule-zh.jpg       | Bin 0 -> 200096 bytes
 .../logging-config-rabbitmq-en.png                 | Bin 0 -> 319041 bytes
 .../logging-config-rabbitmq-zh.png                 | Bin 0 -> 325561 bytes
 .../logging-rabbitmq/logging-option-topic-en.png   | Bin 0 -> 194727 bytes
 .../logging-rabbitmq/logging-option-topic-zh.png   | Bin 0 -> 201168 bytes
 .../logging-rabbitmq-disabled-en.jpg               | Bin 0 -> 328466 bytes
 .../logging-rabbitmq-disabled-zh.jpg               | Bin 0 -> 336882 bytes
 11 files changed, 356 insertions(+)

diff --git a/docs/plugin-center/observability/logging-rabbitmq.md 
b/docs/plugin-center/observability/logging-rabbitmq.md
new file mode 100644
index 0000000000..3e22322ae7
--- /dev/null
+++ b/docs/plugin-center/observability/logging-rabbitmq.md
@@ -0,0 +1,181 @@
+---
+title: Logging-RabbitMQ Plugin
+keywords: ["Logging", "RabbitMQ"]
+description: Logging-RabbitMQ Plugin
+---
+
+# 1. Overview
+
+## 1.1 Plugin Name
+
+* Logging-RabbitMQ Plugin
+
+## 1.2 Appropriate Scenario
+
+* collect http request log to rabbitmq, consume rabbitmq message to another 
application and analysis.
+
+## 1.3 Plugin functionality
+
+>`Apache ShenYu` The gateway receives requests from the client, forwards them 
to the server, and returns the server results to the client. The gateway can 
record the details of each request,    
+> The list includes: request time, request parameters, request path, response 
result, response status code, time consumption, upstream IP, exception 
information waiting.    
+> The Logging-RabbitMQ plugin is a plugin that records access logs and sends 
them to the RabbitMQ cluster.
+
+## 1.4 Plugin code
+
+* Core Module `shenyu-plugin-logging-rabbitmq`.
+
+* Core Class `org.apache.shenyu.plugin.logging.rabbitmq.LoggingRabbitmqPlugin`
+* Core Claas 
`org.apache.shenyu.plugin.logging.rabbitmq.client.RabbitmqLogCollectClient`
+
+## 1.5 Added Since Which shenyu version
+
+* Since ShenYu 2.5.0
+
+## 1.6 Technical Solutions
+
+* Architecture Diagram  
+
+![](/img/shenyu/plugin/logging/shenyu-agent-logging-arch.png)
+
+* Full asynchronous collection and delivery of `Logging` inside the `Apache 
ShenYu` gateway
+
+* Logging platform by consuming the logs in the `RabbitMQ` cluster for 
repository, and then using `Grafana`, `Kibana` or other visualization platform 
to display
+
+
+# 2. How to use plugin
+
+## 2.1 Plugin-use procedure chart
+
+![](/img/shenyu/plugin/plugin_use_en.jpg)
+
+## 2.2 Import pom
+
+* Add the `Logging-RabbitMQ` dependency to the gateway's `pom.xml` file.
+
+```xml
+<!--shenyu logging-rabbitmq plugin start-->
+<dependency>
+    <groupId>org.apache.shenyu</groupId>
+    <artifactId>shenyu-spring-boot-starter-plugin-logging-rabbitmq</artifactId>
+    <version>${project.version}</version>
+</dependency>
+<!--shenyu logging-rabbitmq plugin end-->
+```
+
+## 2.3 Enable plugin
+
+* In `shenyu-admin` --> Basic Configuration --> Plugin Management --> 
`loggingRabbitMQ`, configure the rabbitMQ parameter and set it to on.
+
+## 2.4 Config plugin
+
+### 2.4.1 Open the plugin and configure rabbitmq, configure it as follows.
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png)
+
+* The individual configuration items are described as follows:
+
+| config-item     | type    | description                                      
   | remarks     |
+|:----------------|:--------|:----------------------------------------------------|:------------|
+| host            | type    | IP                                               
   | 必须          |
+| port            | type    | PORT                                             
   | 必须          |
+| username        | String  | rabbitmq username                                
   | 可选          |
+| password        | String  | rabbitmq password                                
   | 可选          |
+| virtualHost     | String  | rabbitmq virtualHost                             
   | 必须,默认/      |
+| exchangeType    | String  | rabbitmq exchange type                           
   | 必须,默认direct |
+| exchangeName    | String  | rabbitmq exchange name                           
   | 必须          |
+| queueName       | String  | rabbitmq queue name                              
   | 必须          |
+| routingKey      | String  | rabbitmq routing key                             
   | 必须          |
+| durable         | Boolean | message durable                                  
   | 必须,默认true   |
+| exclusive       | Boolean | message exclusive                                
   | 必须,默认false  |                                   | 必须,默认false  |
+| autoDelete      | String  | message auto delete                              
   | 必须,默认false  |
+| args            | String  | rabbitmq args,exaple:{"x-delay":"1000"},delay 
queue | 可选          |
+| sampleRate                        | String               | Sampling rate, 
range 0~1, 0: off, 0.01: acquisition 1%, 1: acquisition 100% | Optional, 
default 1, all collection |
+| maxResponseBody                   | Ingeter              | Maximum response 
size, above the threshold no response will be collected                | 
Optional, default 512KB |
+| maxRequestBody                    | Ingeter              | Maximum request 
body size, above the threshold no request body will be collected               
| Optional, default 512KB  |
+Except for 
host,port,virtualHost,exchangeType,exchangeName,queueName,routingKey,durable,exclusive,autoDelete,
 all others are optional.
+
+### 2.4.2 Configuring Selectors and Rulers
+
+* For detailed configuration of selectors and rules, please refer to: 
[Selector and rule management](../../user-guide/admin-usage/selector-and-rule)。
+
+In addition, sometimes a large gateway cluster corresponds to multiple 
applications (business), different applications (business) corresponds to 
different topics, related to isolation,  
+then you can configure different topics (optional) and sampling rate 
(optional) by selector, the meaning of the configuration items as shown in the 
table above.   
+The operation is shown below:
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-en.png)
+
+## 2.5 Logging Info
+
+collect request info as follows
+
+| Field Name                  |                                                
                               Meaning                                          
                                     | Description                            | 
Remarks   |
+|:----------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------|:----|
+| clientIp              |                                                      
                        Client IP                                               
                               |                               |     |
+| timeLocal             |                                                      
  Request time string, format: yyyy-MM-dd HH:mm:ss.SSS                          
                               |                               |     |
+| method                | request method (different rpc type is not the same, 
http class for: get, post wait, rpc class for the interface name) |             
                  |     |
+| requestHeader         |                                                      
              Request header (json format)                                      
                               |                               |     |
+| responseHeader        |                                                      
              Response header (json format)                                     
                               |                               |     |
+| queryParams           |                                                      
                Request query parameters                                        
                               |                               |     |
+| requestBody           |                                                      
 Request Body (body of binary type will not be captured)                        
                               |                               |     |
+| requestUri            |                                                      
                       Request uri                                              
                               |                               |     |
+| responseBody          |                                                      
                      Response body                                             
                               |                               |     |
+| responseContentLength |                                                      
                   Response body size                                           
                               |                               |     |
+| rpcType               |                                                      
                        rpc type                                                
                               |                               |     |
+| status                |                                                      
                     response status                                            
                               |                               |     |
+| upstreamIp            |                                                      
                      Upstream (program providing the service) IP               
                                                               |                
               |     |
+| upstreamResponseTime  |                                                      
                Time taken by the upstream (program providing the service) to 
respond to the request (ms ms)                                                  
                       |                               |     |
+| userAgent             |                                                      
                          Requested user agent                                  
                                              |                               | 
    |
+| host                  |                                                      
                         The requested host                                     
                                          |                               |     
|
+| module                |                                                      
                          Requested modules                                     
                                           |                               |    
 |
+| path                  |                                                      
                       The requested path                                       
                                       |                               |     |
+| traceId                |                                                     
                         Requested Link Tracking ID                             
                                                 | Need to access link tracking 
plugins, such as skywalking,zipkin |     |
+
+
+## 2.6 Examples
+
+### 2.6.1 Collect Http Log by RabbitMQ
+
+#### 2.6.1.1 Plugin Configuration
+
+Open the plugin and configure rabbitmq, configure it as follows.
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png)
+
+#### 2.6.1.2 Selector Configuration
+
+For detailed configuration of selectors and rules, please refer to: [Selector 
and rule management](../../user-guide/admin-usage/selector-and-rule)。
+
+In addition, sometimes a large gateway cluster corresponds to multiple 
applications (business), different applications (business) corresponds to 
different topics, related to isolation,  
+then you can configure different topics (optional) and sampling rate 
(optional) by selector, the meaning of the configuration items as shown in the 
table above.   
+The operation is shown below:
+![](/img/shenyu/plugin/logging/logging-option-topic-en.png)
+
+#### 2.6.1.3 Rule Configuration
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-en.jpg)
+
+#### 2.6.1.4 Request Service
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/call-service.png)
+
+#### 2.6.1.5 Consumption and display of Logging
+
+As each logging platform has differences, such as storage available 
clickhouse, ElasticSearch, etc., visualization has self-developed or open 
source Grafana, Kibana, etc..  
+Logging-RabbitMQ plugin uses RabbitMQ to decouple production and consumption, 
while outputting logs in json format,
+consumption and visualization require users to choose different technology 
stacks to achieve their own situation.
+
+
+#### 2.6.1.6 Panel Display
+
+Users can choose to visualize the implementation according to their own 
situation.   
+The following shows the effect of `Grafana`:  
+[Grafana Sandbox Experience](https://play.grafana.org)
+
+![](/img/shenyu/plugin/logging/grafana-loki-gateway.png)
+
+# 3. How to disable plugin
+
+- In `shenyu-admin` --> BasicConfig --> Plugin --> `loggingRabbitMQ` set 
Status disable.
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-en.jpg)
+
+
diff --git 
a/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/observability/logging-rabbitmq.md
 
b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/observability/logging-rabbitmq.md
new file mode 100644
index 0000000000..7d66714539
--- /dev/null
+++ 
b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/observability/logging-rabbitmq.md
@@ -0,0 +1,175 @@
+---
+title: Logging-RabbitMQ插件
+keywords: ["Logging", "rabbitmq"]
+description: Logging-RabbitMQ插件
+---
+
+# 1. 概述
+
+## 1.1 插件名称
+
+* Logging-RabbitMQ Plugin
+
+## 1.2 适用场景
+
+* 通过rabbitmq收集网关http请求日志,通过其他应用消费rabbitmq消息,并且对日志进行分析。
+
+## 1.3 插件功能
+
+>`Apache ShenYu` 网关接收客户端请求,向服务端转发请求,并将服务端结果返回给客户端.网关可以记录下每次请求对应的详细信息,  
+> 列如: 请求时间、请求参数、请求路径、响应结果、响应状态码、耗时、上游IP、异常信息等待.  
+> Logging-RabbitMQ插件便是记录访问日志并将访问日志发送到RabbitMQ集群的插件.
+
+## 1.4 插件代码
+
+* 核心模块 `shenyu-plugin-logging-rabbitmq`.
+
+* 核心类 `org.apache.shenyu.plugin.logging.rabbitmq.LoggingRabbitmqPlugin`
+* 核心类 
`org.apache.shenyu.plugin.logging.rabbitmq.client.RabbitmqLogCollectClient`
+
+## 1.5 添加自哪个shenyu版本
+
+* ShenYu 2.5.0
+
+## 1.6 技术方案
+
+* 架构图  
+  ![](/img/shenyu/plugin/logging/shenyu-agent-logging-arch.png)
+
+* 在 `Apache ShenYu` 网关里面进行 `Logging` 全程异步采集、异步发送
+
+* 日志平台通过消费`rabbitmq`集群中的日志进行落库,再使用`Grafana`、`Kibana`或者其它可视化平台展示
+
+# 2. 如何使用插件
+
+## 2.1 插件使用流程图
+
+![](/img/shenyu/plugin/plugin_use_zh.jpg)
+
+## 2.2 导入pom
+
+* 在网关的 `pom.xml` 文件中添加 `Logging-rabbitmq` 的依赖。
+
+```xml
+ <!--shenyu logging-rabbitmq plugin start-->
+<dependency>
+    <groupId>org.apache.shenyu</groupId>
+    <artifactId>shenyu-spring-boot-starter-plugin-logging-rabbitmq</artifactId>
+    <version>${project.version}</version>
+</dependency>
+<!--shenyu logging-rabbitmq plugin end-->
+```
+
+## 2.3 启用插件
+
+* 在 `shenyu-admin`--> 基础配置 --> 插件管理-> `loggingRabbitMQ` ,配置rabbitMQ参数,并设置为开启。
+
+## 2.4 配置插件
+
+### 2.4.1 开启插件,并配置rabbitmq,配置如下
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-zh.png)
+
+* 各个配置项说明如下:
+
+| 配置项                 | 类型      | 说明                                           
| 备注        |
+|:--------------------|:--------|:---------------------------------------------|:----------|
+| host                | type    | IP                                           
| 必须        |
+| port                | type    | 端口                                           
| 必须        |
+| username            | String  | 用户名                                          
| 可选   |
+| password            | String  | 密码                                           
| 可选   |
+| virtualHost         | String  | 虚拟主机                                         
| 必须,默认/    |
+| exchangeType        | String  | 交换机类型                                        
| 必须,默认direct |
+| exchangeName        | String  | 交换机名称                                        
| 必须        |
+| queueName           | String  | 队列名称                                         
| 必须        |
+| routingKey          | String  | 路由键                                          
| 必须        |
+| durable             | Boolean | 持久化                                          
| 必须,默认true |
+| exclusive           | Boolean | 是否为排他队列                                      
| 必须,默认false |
+| autoDelete          | String  | 自动删除                                         
| 必须,默认false |
+| args                | String  | rabbitmq参数,例如:{"x-delay":"1000"},表示延时队列,单位ms 
| 可选        |
+| sampleRate          | String  | 采样率,范围0~1,0:关闭,0.01:采集1%,1:采集100%            
| 可选,默认1,全部采集 |
+| maxResponseBody     | Ingeter | 最大响应体大小,超过阈值将不采集响应体                          
| 可选,默认512KB |
+| maxRequestBody      | Ingeter | 最大请求体大小,超过阈值将不采集请求体                          
| 可选,默认512KB |
+*除了host,port,virtualHost,exchangeType,exchangeName,queueName,routingKey,durable,exclusive,autoDelete其它都是可选*。
+
+### 2.4.2 配置选择器和规则器
+
+* 选择器和规则详细配置,请参考: [选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。
+
+另外有时候一个大网关集群对应多个应用程序(业务),不同应用程序(业务)对应不同的主题,相关隔离,这时候可以按选择器配置不同的主题(可选)和采样率(可选),配置项的含义如上表所示。
  
+操作如下图:  
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-zh.png)
+
+
+## 2.5 Logging信息
+
+采集的access log的字段如下:
+
+| 字段名称                  |                       含义                       | 说明  
                          | 备注  |
+|:----------------------|:----------------------------------------------:|:------------------------------|:----|
+| clientIp              |                     客户端IP                      |     
                          |     |
+| timeLocal             |      请求时间字符串,  格式:yyyy-MM-dd HH:mm:ss.SSS      |     
                          |     |
+| method                | 请求方法(不同rpc类型不一样,http类的为:get,post等待,rpc类的为接口名称) |     
                          |     |
+| requestHeader         |                  请求头(json格式)                   |     
                          |     |
+| responseHeader        |                  响应头(json格式)                   |     
                          |     |
+| queryParams           |                     请求查询参数                     |     
                          |     |
+| requestBody           |             请求Body(二进制类型的body不会采集)             |     
                          |     |
+| requestUri            |                     请求uri                      |     
                          |     |
+| responseBody          |                     响应body                     |     
                          |     |
+| responseContentLength |                    响应body大小                    |     
                          |     |
+| rpcType               |                     rpc类型                      |     
                          |     |
+| status                |                      响应码                       |     
                          |     |
+| upstreamIp            |                 上游(提供服务的程序)IP                  |     
                          |     |
+| upstreamResponseTime  |            上游(提供服务的程序)响应请求的耗时(毫秒ms)            |     
                          |     |
+| userAgent             |                    请求的用户代理                     |     
                          |     |
+| host                  |                    请求的host                     |     
                          |     |
+| module                |                     请求的模块                      |     
                          |     |
+| path                  |                   请求的路径path                    |     
                          |     |
+| traceId                |                   请求的链路追踪ID                    | 
需要接入链路追踪插件,如skywalking,zipkin |     |
+
+## 2.6 示例
+
+### 2.6.1 通过RabbitMQ收集请求日志
+
+#### 2.6.1.1 插件配置
+
+开启插件,并配置rabbitmq,配置如下:
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-zh.png)
+
+#### 2.6.1.2 选择器配置
+
+* 选择器和规则详细配置,请参考: [选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。
+
+另外有时候一个大网关集群对应多个应用程序(业务),不同应用程序(业务)对应不同的主题,相关隔离,这时候可以按选择器配置不同的主题(可选)和采样率(可选),配置项的含义如上表所示。
  
+操作如下图:  
+![](/img/shenyu/plugin/logging/logging-option-topic.png)
+
+#### 2.6.1.3 规则配置
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-zh.jpg)
+
+#### 2.6.1.4 请求服务
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/call-service.png)
+
+#### 2.6.1.5 消费以及展示Logging
+
+由于各个日志平台有差异,如存储可用clickhouse,ElasticSearch等待,可视化有自研的或开源的Grafana、Kibana等。  
+Logging-RabbitMQ插件利用RabbitMQ进行生产和消费解耦,同时以json格式输出日志,消费和可视化需要用户结合自身情况选择不同的技术栈来实现。
+
+#### 2.6.1.6 面板展示
+
+用户可根据自身情况选择可视化实现。  
+下面展示下 `Grafana` 效果:
+[Grafana沙盒体验](https://play.grafana.org)
+
+![](/img/shenyu/plugin/logging/grafana-loki-gateway.png)
+
+# 3. 如何禁用插件
+
+- 在 `shenyu-admin` --> 基础配置 --> 插件管理-> loggingRabbitMQ ,设置为关闭。
+
+![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-zh.jpg)
+
+
diff --git a/static/img/shenyu/plugin/logging/logging-rabbitmq/call-service.png 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/call-service.png
new file mode 100644
index 0000000000..35fb056b24
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/call-service.png differ
diff --git a/static/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-en.jpg 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-en.jpg
new file mode 100644
index 0000000000..7702b17b75
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-en.jpg differ
diff --git a/static/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-zh.jpg 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-zh.jpg
new file mode 100644
index 0000000000..ef39fb5248
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-zh.jpg differ
diff --git 
a/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png
 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png
new file mode 100644
index 0000000000..0a875a63bf
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png
 differ
diff --git 
a/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-zh.png
 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-zh.png
new file mode 100644
index 0000000000..8ed3ea68be
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-zh.png
 differ
diff --git 
a/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-en.png 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-en.png
new file mode 100644
index 0000000000..01d495f00a
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-en.png 
differ
diff --git 
a/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-zh.png 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-zh.png
new file mode 100644
index 0000000000..dabcd5cfee
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-zh.png 
differ
diff --git 
a/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-en.jpg
 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-en.jpg
new file mode 100644
index 0000000000..07474351d2
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-en.jpg
 differ
diff --git 
a/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-zh.jpg
 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-zh.jpg
new file mode 100644
index 0000000000..4f271404bb
Binary files /dev/null and 
b/static/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-zh.jpg
 differ

Reply via email to