“This is the first day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021”

This article is my first original article in nuggets, with you to learn some ways to use SkyWalking in micro services, no more nonsense, let’s directly open the whole!

For the convenience and convenience of local development, ALL development environments are installed in Docker

What is a SkyWalking thing?

Simply put, SkyWalking is a link tracking tool that allows you to see the interface from call to finish, including what happens in between, in microservice mode. Wall crack recommended!!

Install Skywalk-OAP in Docker

It needs to be noted that I use a customized network, the network name is my, mainly to facilitate the connection and access between container images. You can directly connect through the container name or container ID

Docker network create my # 2. Docker pull Apache/Skywalking - OAP-server: 8.7.0-ES7 # 3 Start oAP container and connect Elasticsearch, Docker run -d --net my --name Skywalking -oap -e TZ=Asia/Shanghai -p 12800:12800 -p 11800:11800 --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch7 -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 Apache/skywalking - oap - server: 8.7.0 - es7Copy the code
Install Skywalk-UI in Docker
Docker pull Apache/Skywalking - UI :8.7.0 # 5 Start the UI container and connect to the OAP Docker run -d --net my --name Skywalking -ui -e TZ=Asia/Shanghai -p 8088:8080-e SW_OAP_ADDRESS = http://skywalking-oap:12800 apache/skywalking - UI: 8.7.0Copy the code

Visit the UI address: http://localhost:8088/, and if there are no accidents, you can see the following interface

At this point, the SkyWalking environment is installed, and agent probe package is used in the project to monitor link information at buried points

Skywalking user-agent probe package download address: skywalking.apache.org/downloads/, I am here to download skywalking Java agent, version is 8.8.0

After downloading and decompressing, enter the config directory, where there is a configuration file of Agent. Config. We will modify the configuration of the four properties in the following, and the configuration of other properties can be adjusted according to their own needs.

Collect SQL arguments (default is false, Trace_sql_parameters =${SW_JDBC_TRACE_SQL_PARAMETERS:true} # Collect SpringMVC request parameters (default is false, Plugin.springmvc. Collect_http_params =${SW_PLUGIN_SPRINGMVC_COLLECT_HTTP_PARAMS:true} # Collect Http client request parameters (default False, Here to true) plugin. Httpclient. Collect_http_params = ${SW_PLUGIN_HTTPCLIENT_COLLECT_HTTP_PARAMS: true} # collection feign call request body Plugin.feign. collect_request_body=${SW_PLUGIN_FEIGN_COLLECT_REQUEST_BODY:true}Copy the code

* note: * If your project service entry is gateway, Add apM-spring-cloud-gateway-2.1.x-plugin-8.8.0.jar to the optional plugins folder Apm – spring – webflux – 5. X – the plugin – 8.8.0. Two jar jar package into the plugins directory, otherwise you will not be able to link the gateway tracking!!!!!!

Implant the Agent probe package and start the project through the Agent probe package

Here I use IDEA to demonstrate by adding 3 parameters to project JVM parameters, as shown in the figure below

– javaAgent: specifies the path where the probe package resides

– Dskywalking. Agent. Service_name: specify the name of the current service (by definition)

– Dskywalking. Collector. Backend_service: specifies the oap to connect the service, the above has been set up

I’m going to start three services at once, show you (all with probe packages, same JVM parameters except service names), and then see your service information on the topology

And if you call the interface, you can see the link information of the interface call in the trace (including the SQL executed by mysql, feign calls between services, Redis calls, etc.), very clear.

Some query parameters in the interface are also visible

Body and Response. body are displayed in the last picture, so why didn’t I build them myself? Oh, these are small problems. How do I customize Tag information in SkyWalking?

All right, the construction of SkyWalking and its use in the project are completed. Thank you for watching and learning together! Common progress, chong duck!