Skip to main content
Version: 2.12

skywalking-logger

Summary#

Name#

skywalking-logger is a plugin which push Access Log data to SkyWalking OAP server over HTTP. If there is tracing context existing, it sets up the trace-log correlation automatically, and relies on SkyWalking Cross Process Propagation Headers Protocol.

This will provide the ability to send Access Log as JSON objects to SkyWalking OAP server.

Attributes#

NameTypeRequirementDefaultValidDescription
endpoint_addrstringrequiredThe URI of the SkyWalking OAP server.
service_namestringoptional"APISIX"service name for SkyWalking reporter.
service_instance_namestringoptional"APISIX Instance Name"service instance name for SkyWalking reporter, set it to $hostname to get local hostname directly.
timeoutintegeroptional3[1,...]Time to keep the connection alive after sending a request.
namestringoptional"skywalking logger"A unique identifier to identity the logger.
batch_max_sizeintegeroptional1000[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 SkyWalking OAP server.
inactive_timeoutintegeroptional5[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 SkyWalking OAP server regardless of whether the number of logs in the buffer reaches the maximum number set.
buffer_durationintegeroptional60[1,...]Maximum age in seconds of the oldest entry in a batch before the batch must be processed.
max_retry_countintegeroptional0[0,...]Maximum number of retries before removing from the processing pipe line.
retry_delayintegeroptional1[0,...]Number of seconds the process execution should be delayed if the execution fails.
include_req_bodybooleanoptionalfalse[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.

How To Enable#

The following is an example of how to enable the skywalking-logger for a specific route. Before that, an available SkyWalking OAP server was required and accessible.

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"skywalking-logger": {
"endpoint_addr": "http://127.0.0.1:12800"
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
},
"uri": "/hello"
}'

Test Plugin#

success:

$ curl -i http://127.0.0.1:9080/hello
HTTP/1.1 200 OK
...
hello, world

Completion of the steps, could find the Log details on SkyWalking UI.

Metadata#

skywalking-logger also supports to custom log format like http-logger.

NameTypeRequirementDefaultValidDescription
log_formatobjectoptional{"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"}Log format declared as key value pair in JSON format. Only string is supported in the value part. If the value starts with $, it means to get APISIX variables or Nginx variable.

Note that the metadata configuration is applied in global scope, which means it will take effect on all Route or Service which use skywalking-logger plugin.

Disable Plugin#

Remove the corresponding json configuration in the plugin configuration to disable the skywalking-logger. APISIX plugins are hot-reloaded, therefore no need to restart APISIX.

$ curl http://127.0.0.1:9080/apisix/admin/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"plugins": {},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}'