Skip to content

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.

image

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

image

1.2 Enable Collectors

To enable RUM, you need to allow remote access to DataKit’s port 9529. Edit the following file:

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

Change 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

  • 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 to skywalking-service-log

image

1.3 Restart DataKit

systemctl 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.

image

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

image

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>
```
  1. Output logs, including traceId. image

2.2 Deploy Web

Enter the web project directory and run cnpm install in the command line.

image

Run npm run build to generate 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 service 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 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.

image

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.

image

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.

image

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 to ddtrace, 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.

image

image

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».

image

Select «Trace»

image

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

image

Feedback

Is this page helpful? ×