Skip to main content
Version: Next

1. Overview

1.1 Plugin Name#

  • Logging-HuaweiLts Plugin

1.2 Appropriate Scenario#

  • collect http request information to huawei lts, analysis request information by huawei lts 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 huawei lts platform.

1.4 Plugin code#

  • Core Module shenyu-plugin-logging-huawei-lts

  • Core Class org.apache.shenyu.plugin.huawei.lts.LoggingHuaweiLtsPlugin

  • Core Class org.apache.shenyu.plugin.huawei.lts.client.HuaweiLtsLogCollectClient

1.5 Added Since Which shenyu version#

ShenYu 2.6.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-huaweilts plugin start --><dependency>    <groupId>org.apache.shenyu</groupId>    <artifactId>shenyu-spring-boot-starter-plugin-logging-huawei-lts</artifactId>    <version>${project.version}</version></dependency><!-- shenyu logging-huaweilts plugin end -->

2.3 Enable plugin#

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

2.4 Config plugin#

2.4.1 Plugin configuration#

config-itemdescriptiontyperemarks
projectIdThe project ID of the HUAWEI CLOUD account(project id)Stringmust
accessKeyIdAK of the HUAWEI CLOUD accountStringmust
accessKeySecretSK of HUAWEI CLOUD accountStringmust
regionNameRegions of Cloud Log ServiceStringmust
logGroupIdThe log group ID of the LTSStringmust
logStreamIdThe log stream ID of the LTSStringmust
totalSizeInBytesThe upper limit of the log size that can be cached by a single producer instanceintoptional
maxBlockMsIf the producer has insufficient free space, the caller's maximum block time on the send method, in milliseconds. The default is 60 seconds (60000 milliseconds), and 0 seconds is recommended. When the maxBlockMs value >= 0, it will block until the set time. If the blocking time is reached, the memory cannot be obtained, that is, an error will be reported and the log will be discarded. When the value of maxBlockMs=-1, it will be blocked until the sending is successful, and the log will not be discardedlongoptional
ioThreadCountThe thread pool size for executing log sending tasksintoptional
batchSizeThresholdInBytesWhen the cached log size in a ProducerBatch is greater than or equal to batchSizeThresholdInBytes, the batch will be sentintoptional
batchCountThresholdWhen the number of cached logs in a ProducerBatch is greater than or equal to batchCountThreshold, the batch will be sentintoptional
lingerMsThe lingering time of a ProducerBatch from creation until it is sendableintoptional
retriesIf a ProducerBatch fails to send for the first time, the number of times it can be retried is recommended to be 3 times. If retries is less than or equal to 0, the ProducerBatch will directly enter the failure queue after the first sending failureintoptional
baseRetryBackoffMsThe backoff time for the first retrylongoptional
maxRetryBackoffMsMaximum backoff time for retrieslongoptional
giveUpExtraLongSingleLogFor logs exceeding 1M, the data larger than 1M will be discarded after splittingbooleanoptional
enableLocalTest是否开启跨云上报日志booleanoptional
  • get regionName

区域名称RegionName
华北-北京二cn-north-2
华北-北京四cn-north-4
华北-北京一cn-north-1
华东-上海二cn-east-2
华东-上海一cn-east-3
华南-广州cn-south-1
华南-深圳cn-south-2
西南-贵阳一cn-southwest-2
  • get projectId

  • get accessKeyId and accessKeySecret

  • get logGroupId and logStreamId

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 tencent cls platform#

2.6.1.1 Plugin Configuration#

  • Open the plugin and configure huawei lts, 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 Huawei lts Platform Display#

3. How to disable plugin

  • In shenyu-admin --> BasicConfig --> Plugin -->loggingHuaweiLtsset Status disable.