Based on Guance, Achieving RUM, APM, and Log Correlation Analysis with SkyWalking¶
Use Cases¶
In a distributed application environment, issues are often diagnosed through logs and traces. Guance enables users to associate requests made via the Web interface with backend interfaces using traceId. If the backend interface outputs logs, the traceId links the trace and the log together, ultimately forming RUM, APM, and log correlation. Utilizing the Guance platform for comprehensive analysis allows for convenient and quick identification and localization of problems.
This article uses an easy-to-follow open-source project as an example to achieve full-chain observability step by step.
Prerequisites¶
- You need to first create a Guance account.
- Spring Boot and Vue applications.
- A Linux server with Nginx installed.
Steps¶
Warning
The version information used in this example is as follows: DataKit 1.4.15
, SkyWalking 8.7.0
, Nginx 1.20.2
, JDK 1.8
, Vue 3.2
1 Deploy DataKit¶
1.1 Install DataKit¶
Log in to «Guance», navigate sequentially to «Integration» - «DataKit» - «Linux», and click «Copy Icon» to copy the installation command.
Log in to the Linux server and execute the copied command.
1.2 Enable Collector¶
To enable RUM, allow remote access to port 9529 of DataKit by editing the following file.
Change the listen value to 0.0.0.0:9529
Copy the conf file to enable the SkyWalking collector.
Enable the log collector.
Edit the skywalking-service-log.conf
file.
- Set logfiles to the log file path; since the jar will be deployed to
/usr/local/df-demo/skywalking
, the log path here is/usr/local/df-demo/skywalking/logs/log.log
- Source should be
skywalking-service-log
1.3 Restart DataKit¶
2 Deploy Application¶
2.1 Deploy Backend Service¶
Download the skywalking-demo project, open it with Idea, and click «package» to generate the skywalking-user-service.jar
file.
Upload skywalking-user-service.jar
to the /usr/local/df-demo/skywalking
directory.
Note:
1. Add dependencies to the project
```xml
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-logback-1.x</artifactId>
<version>8.7.0</version>
</dependency>
```
2.2 Deploy Web¶
Navigate to the web project directory and run cnpm install
from the command line.
Run npm run build
to generate deployment files.
Copy the files under the disk directory to the /usr/local/web
directory on the server.
Edit the /etc/nginx/nginx.conf
file and add the following content.
Reload the nginx configuration.
Input the Linux service IP in the browser to access the frontend interface.
3 Enable APM¶
Download SkyWalking
Upload the agent directory to the /usr/local/df-demo/skywalking
directory on Linux.
If the microservice uses springcloud gateway, you must copy agent/optional-plugins/
's apm-spring-cloud-gateway-2.1.x-plugin-8.7.0.jar
and apm-spring-webflux-5.x-plugin-8.7.0.jar
to the skywalking-agent/plugins/
directory.
Note: The version of apm-spring-cloud-gateway must correspond to the specific version of the springcloud gateway being used.
cp /usr/local/df-demo/skywalking/agent/optional-plugins/apm-spring-cloud-gateway-2.1.x-plugin-8.7.0.jar /usr/local/df-demo/skywalking/agent/plugins/
cp /usr/local/df-demo/skywalking/agent/optional-plugins/apm-spring-webflux-5.x-plugin-8.7.0.jar /usr/local/df-demo/skywalking/agent/plugins/
Execute the following command to start the backend service, click the button on the frontend interface to call the backend service.
cd /usr/local/df-demo/skywalking
java -javaagent:agent/skywalking-agent.jar -Dskywalking.agent.service_name=skywalking-log -Dskywalking.collector.backend_service=localhost:11800 -jar skywalking-user-service.jar
Log in to «Guance», navigate to «Application Performance Monitoring», and check the services, traces, and topology diagram.
4 Enable RUM¶
Log in to «Guance», navigate to «User Access Monitoring», create a new application named skywalking-web-demo, and copy the JS code below.
Modify /usr/local/web/index.html
and paste the JS into the head section.
- Change datakitOrigin to the address of DataKit, which is the Linux IP address plus port 9529
- allowedTracingOrigins is the address of the backend interface, which is the Linux IP address plus port 8090
Parameter descriptions:
- datakitOrigin: Data transmission address, which is the domain name or IP of datakit, required.
- env: Application's environment, required.
- version: Application's version, required.
- trackInteractions: Whether to enable user behavior statistics, such as clicking buttons, submitting information, etc., required.
- traceType: Trace type, default is ddtrace, optional.
- allowedTracingOrigins: To connect APM and RUM chains, fill in the domain name or IP of the backend service, optional.
Click the button on the frontend interface. Log in to «Guance» - «User Access Monitoring», click «skywalking-web-demo», and view UV, PV, session count, visited pages, and other information.
5 Full Chain Observability¶
Log in to «Guance» - «User Access Monitoring», click «skywalking-web-demo», then enter and click «Explorer», select «View», and check the page invocation situation. Then click «route_change» to proceed.
Select «Service Map»
Click on a request record, where you can observe the "Flame Graph", "Span List", "Service Call Relationship", and the logs generated by this chain invocation.