Skip to content

Using SkyWalking to Achieve Correlated Analysis of RUM, APM, and Logs Based on Guance


Use Cases

In distributed application environments, troubleshooting often relies on logs and traces. Guance can correlate requests made by users through the Web with backend interfaces via traceId. If the backend interfaces output logs, the traces and logs are correlated through traceId, ultimately forming a correlation of RUM, APM, and logs. Using the Guance platform for comprehensive analysis makes it very convenient to quickly discover and locate issues.

This article uses a simple, easy-to-use open-source project as an example to implement full-link observability step by step.

Prerequisites

  • You need to first create a Guance account.
  • Spring Boot and Vue applications.
  • A Linux server with Nginx deployed.

Configuration Steps

Warning

The version information used in this article's examples 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 to 「Integrations」 - 「DataKit」 - 「Linux」, and click the 「Copy icon」 to copy the installation command.

image

Log in to the Linux server and execute the copied command.

image

1.2 Enable Collectors

To enable RUM, users need remote access to DataKit's port 9529. Edit the following file.

vi /usr/local/datakit/conf.d/datakit.conf

Modify the listen value to 0.0.0.0:9529

image

Copy the conf file to enable the SkyWalking collector.

cd /usr/local/datakit/conf.d/skywalking
cp skywalking.conf.sample skywalking.conf

Enable the log collector.

cd /usr/local/datakit/conf.d/log
cp logging.conf.sample skywalking-service-log.conf

Edit the skywalking-service-log.conf file

  • logfiles: fill in the log file path. Since the jar will be deployed to the /usr/local/df-demo/skywalking directory, the log path here is /usr/local/df-demo/skywalking/logs/log.log.
  • source: set to skywalking-service-log.

image

1.3 Restart DataKit

systemctl restart datakit

2 Deploy Applications

2.1 Deploy Backend Service

Download the skywalking-demo project, open it with IntelliJ IDEA, and click the 「package」 button on the right to generate the skywalking-user-service.jar file.

image

Upload skywalking-user-service.jar to the /usr/local/df-demo/skywalking directory.

image

Note:
1. The project needs to add the dependency
.

```xml
        <dependency>
            <groupId>org.apache.skywalking</groupId>
            <artifactId>apm-toolkit-logback-1.x</artifactId>
            <version>8.7.0</version>
        </dependency>
```
  1. When outputting logs, the traceId must be output. image

2.2 Deploy Web

Navigate to the web project directory and execute cnpm install in the command line.

image

Execute npm run build to generate the deployment files.

image

Copy the files under the disk directory to the /usr/local/web directory on the server.

image

image

Edit the /etc/nginx/nginx.conf file and add the following content.

   location / {
            root   /usr/local/web;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;

        }

image

Reload the nginx configuration.

nginx -s reload

Enter the Linux server IP in the browser to access the frontend interface.

image

3 Enable APM

Download SkyWalking

Upload the agent directory to the /usr/local/df-demo/skywalking directory on the Linux server.

image

image

If the microservice uses Spring Cloud Gateway, copy agent/optional-plugins/, 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 directory to the skywalking-agent/plugins/ directory.

Note: The version of apm-spring-cloud-gateway must correspond to the specific version of Spring Cloud Gateway in use.

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, then 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」, go to 「Application Performance Monitoring」, and view the services, traces, and service map.

image

4 Enable RUM

Log in to 「Guance」, go to 「Real User Monitoring」, create a new application skywalking-web-demo, and copy the JS below.

image

Modify /usr/local/web/index.html, paste the JS into the <head> section.

  • Modify datakitOrigin to the DataKit address (Linux server IP + port 9529).
  • allowedTracingOrigins to the backend service address (Linux server IP + port 8090).

image

Parameter Description

  • datakitOrigin: The data transmission address, which is the DataKit domain name or IP. Required.
  • env: The environment of the application. Required.
  • version: The version of the application. Required.
  • trackInteractions: Whether to enable user behavior tracking, e.g., button clicks, form submissions. Required.
  • traceType: The trace type, defaults to ddtrace. Optional.
  • allowedTracingOrigins: Enables correlation between APM and RUM traces. Fill in the backend service domain name or IP. Optional.

Click the button on the frontend interface. Log in to 「Guance」 - 「Real User Monitoring」, click 「skywalking-web-demo」, and view UV, PV, session count, visited pages, and other information.

image

image

Log in to 「Guance」 - 「Real User Monitoring」, click 「skywalking-web-demo」, then click 「Explorer」, select 「view」, review the page call details, and then click 「route_change」 to enter.

image

Select 「Traces」

image

Click on a request record to observe the "Flame Graph", "Span List", "Service Call Relationships", and the logs generated by this trace.

image

Feedback

Is this page helpful?