skywalking
The SkyWalking server can support both HTTP and gRPC protocols. Currently, the APISIX client only supports the HTTP protocol.
Attributes
First of all, enable the SkyWalking plugin in the :
Then reload APISIX, a background timer will be created to report data to the SkyWalking OAP server.
Here’s an example, enable the SkyWalking plugin on the specified route:
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uris": [
"/uid/*"
],
"plugins": {
"skywalking": {
"sample_ratio": 1
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"10.110.149.175:8089": 1
}
}'
You also can complete the above operation through the web interface, first add a route, then add SkyWalking plugin:
How to set endpoint
We can set the endpoint by specifying the configuration in .
Name | Type | Default | Description |
---|---|---|---|
service_name | string | “APISIX” | service name for SkyWalking reporter |
service_instance_name | string | “APISIX Instance Name” | service instance name for SkyWalking reporter, set it to $hostname to get local hostname directly. |
endpoint_addr | string | “http://127.0.0.1:12800” | the HTTP endpoint of SkyWalking, for example: |
report_interval | integer | use the value in the SkyWalking client library | the report interval, in seconds |
Here is an example:
plugin_attr:
skywalking:
service_name: APISIX
service_instance_name: "APISIX Instance Name"
endpoint_addr: http://127.0.0.1:12800
Start the SkyWalking OAP Server:
By default, SkyWalking uses H2 storage, start SkyWalking directly by
sudo docker run --name skywalking -d -p 1234:1234 -p 12800:12800 --restart always apache/skywalking-oap-server:8.7.0-es6
-
First, you should install Elasticsearch:
sudo docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 --restart always -e "discovery.type=single-node" elasticsearch:6.7.2
Optionally, you can install ElasticSearch management page: elasticsearch-hq
Finally, run SkyWalking OAP server:
sudo docker run --name skywalking -d -p 1234:1234 -p 12800:12800 --restart always --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 apache/skywalking-oap-server:8.7.0-es6
SkyWalking Web UI:
Run SkyWalking web UI Server:
sudo docker run --name skywalking-ui -d -p 8080:8080 --link skywalking:skywalking -e SW_OAP_ADDRESS=skywalking:12800 --restart always apache/skywalking-ui
Access the web UI of SkyWalking: You can access the dashboard from a browser: http://10.110.149.175:8080 It will show the following if the installation is successful.
Test:
Access to upstream services through accessing APISIX:
$ curl -v http://10.110.149.192:9080/uid/12
OK
...
Open the web UI of SkyWalking:
http://10.110.149.175:8080/
\ You can also see the traces from all services\
Disable Plugin
When you want to disable the SkyWalking plugin on a route/service, it is very simple, you can delete the corresponding JSON configuration in the plugin configuration, no need to restart the service, it will take effect immediately:
The SkyWalking plugin has been disabled now. The step works in the same fashion for other plugins.
If you want to completely disable the SkyWalking plugin, for example, stopping the background report timer, you will need to comment out the plugin in the config.yaml
:
plugins:
- ... # plugin you need
And then reload APISIX.
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
public class TestController {
@RequestMapping("/uid/{count}")
public String getUidList(@PathVariable("count") String countStr, HttpServletRequest request) {
return "OK";
}
}
Configure the SkyWalking agent when starting the service.
Update the file of agent/config/agent.config
agent.service_name=yourservername
collector.backend_service=10.110.149.175:11800
Run the script:
nohup java -javaagent:/root/skywalking/app/agent/skywalking-agent.jar \
-jar /root/skywalking/app/app.jar \