Skip to content

Commit 793c500

Browse files
authored
doc plugin-logging-rabbitmq:add config doc. (#1045)
1 parent 3fc207b commit 793c500

File tree

11 files changed

+356
-0
lines changed

11 files changed

+356
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
---
2+
title: Logging-RabbitMQ Plugin
3+
keywords: ["Logging", "RabbitMQ"]
4+
description: Logging-RabbitMQ Plugin
5+
---
6+
7+
# 1. Overview
8+
9+
## 1.1 Plugin Name
10+
11+
* Logging-RabbitMQ Plugin
12+
13+
## 1.2 Appropriate Scenario
14+
15+
* collect http request log to rabbitmq, consume rabbitmq message to another application and analysis.
16+
17+
## 1.3 Plugin functionality
18+
19+
>`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,
20+
> The list includes: request time, request parameters, request path, response result, response status code, time consumption, upstream IP, exception information waiting.
21+
> The Logging-RabbitMQ plugin is a plugin that records access logs and sends them to the RabbitMQ cluster.
22+
23+
## 1.4 Plugin code
24+
25+
* Core Module `shenyu-plugin-logging-rabbitmq`.
26+
27+
* Core Class `org.apache.shenyu.plugin.logging.rabbitmq.LoggingRabbitmqPlugin`
28+
* Core Claas `org.apache.shenyu.plugin.logging.rabbitmq.client.RabbitmqLogCollectClient`
29+
30+
## 1.5 Added Since Which shenyu version
31+
32+
* Since ShenYu 2.5.0
33+
34+
## 1.6 Technical Solutions
35+
36+
* Architecture Diagram
37+
38+
![](/img/shenyu/plugin/logging/shenyu-agent-logging-arch.png)
39+
40+
* Full asynchronous collection and delivery of `Logging` inside the `Apache ShenYu` gateway
41+
42+
* Logging platform by consuming the logs in the `RabbitMQ` cluster for repository, and then using `Grafana`, `Kibana` or other visualization platform to display
43+
44+
45+
# 2. How to use plugin
46+
47+
## 2.1 Plugin-use procedure chart
48+
49+
![](/img/shenyu/plugin/plugin_use_en.jpg)
50+
51+
## 2.2 Import pom
52+
53+
* Add the `Logging-RabbitMQ` dependency to the gateway's `pom.xml` file.
54+
55+
```xml
56+
<!--shenyu logging-rabbitmq plugin start-->
57+
<dependency>
58+
<groupId>org.apache.shenyu</groupId>
59+
<artifactId>shenyu-spring-boot-starter-plugin-logging-rabbitmq</artifactId>
60+
<version>${project.version}</version>
61+
</dependency>
62+
<!--shenyu logging-rabbitmq plugin end-->
63+
```
64+
65+
## 2.3 Enable plugin
66+
67+
* In `shenyu-admin` --> Basic Configuration --> Plugin Management --> `loggingRabbitMQ`, configure the rabbitMQ parameter and set it to on.
68+
69+
## 2.4 Config plugin
70+
71+
### 2.4.1 Open the plugin and configure rabbitmq, configure it as follows.
72+
73+
![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png)
74+
75+
* The individual configuration items are described as follows:
76+
77+
| config-item | type | description | remarks |
78+
|:----------------|:--------|:----------------------------------------------------|:------------|
79+
| host | type | IP | 必须 |
80+
| port | type | PORT | 必须 |
81+
| username | String | rabbitmq username | 可选 |
82+
| password | String | rabbitmq password | 可选 |
83+
| virtualHost | String | rabbitmq virtualHost | 必须,默认/ |
84+
| exchangeType | String | rabbitmq exchange type | 必须,默认direct |
85+
| exchangeName | String | rabbitmq exchange name | 必须 |
86+
| queueName | String | rabbitmq queue name | 必须 |
87+
| routingKey | String | rabbitmq routing key | 必须 |
88+
| durable | Boolean | message durable | 必须,默认true |
89+
| exclusive | Boolean | message exclusive | 必须,默认false | | 必须,默认false |
90+
| autoDelete | String | message auto delete | 必须,默认false |
91+
| args | String | rabbitmq args,exaple:{"x-delay":"1000"},delay queue | 可选 |
92+
| sampleRate | String | Sampling rate, range 0~1, 0: off, 0.01: acquisition 1%, 1: acquisition 100% | Optional, default 1, all collection |
93+
| maxResponseBody | Ingeter | Maximum response size, above the threshold no response will be collected | Optional, default 512KB |
94+
| maxRequestBody | Ingeter | Maximum request body size, above the threshold no request body will be collected | Optional, default 512KB |
95+
Except for host,port,virtualHost,exchangeType,exchangeName,queueName,routingKey,durable,exclusive,autoDelete, all others are optional.
96+
97+
### 2.4.2 Configuring Selectors and Rulers
98+
99+
* For detailed configuration of selectors and rules, please refer to: [Selector and rule management](../../user-guide/admin-usage/selector-and-rule)
100+
101+
In addition, sometimes a large gateway cluster corresponds to multiple applications (business), different applications (business) corresponds to different topics, related to isolation,
102+
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.
103+
The operation is shown below:
104+
![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-option-topic-en.png)
105+
106+
## 2.5 Logging Info
107+
108+
collect request info as follows
109+
110+
| Field Name | Meaning | Description | Remarks |
111+
|:----------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------|:----|
112+
| clientIp | Client IP | | |
113+
| timeLocal | Request time string, format: yyyy-MM-dd HH:mm:ss.SSS | | |
114+
| method | request method (different rpc type is not the same, http class for: get, post wait, rpc class for the interface name) | | |
115+
| requestHeader | Request header (json format) | | |
116+
| responseHeader | Response header (json format) | | |
117+
| queryParams | Request query parameters | | |
118+
| requestBody | Request Body (body of binary type will not be captured) | | |
119+
| requestUri | Request uri | | |
120+
| responseBody | Response body | | |
121+
| responseContentLength | Response body size | | |
122+
| rpcType | rpc type | | |
123+
| status | response status | | |
124+
| upstreamIp | Upstream (program providing the service) IP | | |
125+
| upstreamResponseTime | Time taken by the upstream (program providing the service) to respond to the request (ms ms) | | |
126+
| userAgent | Requested user agent | | |
127+
| host | The requested host | | |
128+
| module | Requested modules | | |
129+
| path | The requested path | | |
130+
| traceId | Requested Link Tracking ID | Need to access link tracking plugins, such as skywalking,zipkin | |
131+
132+
133+
## 2.6 Examples
134+
135+
### 2.6.1 Collect Http Log by RabbitMQ
136+
137+
#### 2.6.1.1 Plugin Configuration
138+
139+
Open the plugin and configure rabbitmq, configure it as follows.
140+
141+
![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-config-rabbitmq-en.png)
142+
143+
#### 2.6.1.2 Selector Configuration
144+
145+
For detailed configuration of selectors and rules, please refer to: [Selector and rule management](../../user-guide/admin-usage/selector-and-rule)
146+
147+
In addition, sometimes a large gateway cluster corresponds to multiple applications (business), different applications (business) corresponds to different topics, related to isolation,
148+
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.
149+
The operation is shown below:
150+
![](/img/shenyu/plugin/logging/logging-option-topic-en.png)
151+
152+
#### 2.6.1.3 Rule Configuration
153+
154+
![](/img/shenyu/plugin/logging/logging-rabbitmq/log-rule-en.jpg)
155+
156+
#### 2.6.1.4 Request Service
157+
158+
![](/img/shenyu/plugin/logging/logging-rabbitmq/call-service.png)
159+
160+
#### 2.6.1.5 Consumption and display of Logging
161+
162+
As each logging platform has differences, such as storage available clickhouse, ElasticSearch, etc., visualization has self-developed or open source Grafana, Kibana, etc..
163+
Logging-RabbitMQ plugin uses RabbitMQ to decouple production and consumption, while outputting logs in json format,
164+
consumption and visualization require users to choose different technology stacks to achieve their own situation.
165+
166+
167+
#### 2.6.1.6 Panel Display
168+
169+
Users can choose to visualize the implementation according to their own situation.
170+
The following shows the effect of `Grafana`:
171+
[Grafana Sandbox Experience](https://play.grafana.org)
172+
173+
![](/img/shenyu/plugin/logging/grafana-loki-gateway.png)
174+
175+
# 3. How to disable plugin
176+
177+
- In `shenyu-admin` --> BasicConfig --> Plugin --> `loggingRabbitMQ` set Status disable.
178+
179+
![](/img/shenyu/plugin/logging/logging-rabbitmq/logging-rabbitmq-disabled-en.jpg)
180+
181+

0 commit comments

Comments
 (0)