Based on Guance, Implementing RUM, APM, and Log Correlation Analysis with SkyWalking¶
Use Cases¶
In a distributed application environment, issues are often diagnosed using logs and traces. Guance enables user requests made through the web interface to be associated with backend APIs via traceId
. If the backend API outputs logs, these logs can be correlated with traces using the traceId
, ultimately forming RUM, APM, and log correlation. By leveraging the Guance platform for comprehensive analysis, it becomes very convenient and quick to identify and pinpoint issues.
This article uses a simple and easy-to-follow open-source project as an example, step by step implementing full-stack observability.
Prerequisites¶
- You need to first create a Guance account.
- Spring Boot and Vue applications.
- A Linux server with Nginx installed.
Procedure¶
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 the «Guance», sequentially enter «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 Collectors¶
To enable RUM, you need to allow remote access to DataKit’s port 9529. Edit 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 path of the log files. 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
- Set
source
toskywalking-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» on the right 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¶
Enter the web project directory and run cnpm install
in 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.
Enter 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 the Linux server.
If your microservice uses Spring Cloud Gateway, you must copy the apm-spring-cloud-gateway-2.1.x-plugin-8.7.0.jar
and apm-spring-webflux-5.x-plugin-8.7.0.jar
from the agent/optional-plugins/
directory to the skywalking-agent/plugins/
directory.
Note: The version of
apm-spring-cloud-gateway
must match the specific version of the Spring Cloud Gateway you are using.
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/
Run the following command to start the backend service and 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», enter «Application Performance Monitoring», and view services, traces, and topology maps.
4 Enable RUM¶
Log in to «Guance», enter «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 code into the <head>
section.
- Change
datakitOrigin
to the address of DataKit, which is the Linux IP address plus port 9529. - Set
allowedTracingOrigins
to the backend API address, which is the Linux IP address plus port 8090.
Parameter Description
datakitOrigin
: Data transmission address, which is the domain name or IP of DataKit, required.env
: Environment to which the application belongs, required.version
: Version to which the application belongs, required.trackInteractions
: Whether to enable user interaction tracking, such as clicking buttons or submitting information, required.traceType
: Type of trace, defaults toddtrace
, optional.allowedTracingOrigins
: To achieve correlation between APM and RUM traces, 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 on «skywalking-web-demo», and view UV, PV, session count, visited pages, etc.
5 Full-Stack Observability¶
Log in to «Guance» - «User Access Monitoring», click on «skywalking-web-demo», then click «Explorer», select «View», view page calls, and then click «route_change».
Select «Trace»
Click on a request record to observe the "Flame Graph", "Span List", "Service Call Relationships", and logs generated by this trace.