Skip to main content
Version: Next

1. Overview

1.1 Plugin Name#

  • Logging-AliyunSls Plugin

1.2 Appropriate Scenario#

  • collect http request information to aliyun sls, analysis request information by aliyun sls platform.

1.3 Plugin functionality#

  • 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 plugin records access logs and sends to aliyun sls platform.

1.4 Plugin code#

  • Core Module shenyu-plugin-logging-aliyun-sls

  • Core Class org.apache.shenyu.plugin.aliyun.sls.LoggingAliYunSlsPlugin

  • Core Class org.apache.shenyu.plugin.aliyun.sls.client.AliyunSlsLogCollectClient

1.5 Added Since Which shenyu version#

ShenYu 2.5.0

2. How to use plugin

2.1 Plugin-use procedure chart#

2.2 Import pom#

  • import maven config in shenyu-bootstrap project's pom.xml file.
<!-- shenyu logging-aliyunsls plugin start --><dependency>  <groupId>org.apache.shenyu</groupId>  <artifactId>shenyu-spring-boot-starter-plugin-logging-aliyun-sls</artifactId>  <version>${project.version}</version></dependency><!-- shenyu logging-aliyunsls plugin end -->

2.3 Enable plugin#

  • In shenyu-admin --> BasicConfig --> Plugin --> loggingAliyunSls set Status enable.

2.4 Config plugin#

2.4.1 Plugin configuration#

config-itemtypedescriptionremarks
accessIdStringaccessIdmust
accesskeyStringaccesskeymust
hostStringhost name, example:cn-guangzhou.log.aliyuncs.commust
projectNameStringlog project nameoptional, default shenyu
logStoreNameStringlog store nameoptional, default shenyu-logstore
topicStringaliyun sls log topicoptional, default shenyu-topic
ttlInDayIntegerttl times in one dayoptional, default 3
shardCountIntegeraliyun sls log shard countoptional, default 10
sendThreadCountIntegersend log to aliyun sls thread numberoptional, default 1
ioThreadCountIntegerio thread countoptional, default 1
sampleRateStringsample consume rateoptional, default 1
maxRequestBodyIntegermax request bodyoptional, default 524288
maxResponseBodyIntegermax response bodyoptional, default 524288
bufferQueueSizeIntegerconsume log queue sizeoptional, default 50000

2.4.2 Configuration Selectors and Rules#

2.5 Logging Info#

collect request info as follows

Field NameMeaningDescriptionRemarks
clientIpClient IP
timeLocalRequest time string, format: yyyy-MM-dd HH:mm:ss.SSS
methodrequest method (different rpc type is not the same, http class for: get, post wait, rpc class for the interface name)
requestHeaderRequest header (json format)
responseHeaderResponse header (json format)
queryParamsRequest query parameters
requestBodyRequest Body (body of binary type will not be captured)
requestUriRequest uri
responseBodyResponse body
responseContentLengthResponse body size
rpcTyperpc type
statusresponse status
upstreamIpUpstream (program providing the service) IP
upstreamResponseTimeTime taken by the upstream (program providing the service) to respond to the request (ms ms)
userAgentRequested user agent
hostThe requested host
moduleRequested modules
pathThe requested path
traceIdRequested Link Tracking IDNeed to access link tracking plugins, such as skywalking,zipkin

2.6 Examples#

2.6.1 Collect Http Log by aliyun sls platform#

2.6.1.1 Plugin Configuration#

  • Open the plugin and configure aliyun-sls, configure it as follows.

2.6.1.2 Selector Configuration#

2.6.1.3 Rule Configuration#

2.6.1.4 Send Request#

2.6.1.5 Aliyun sls Platform Display#

3. How to disable plugin

  • In shenyu-admin --> BasicConfig --> Plugin --> loggingAliyunSls set Status disable.