qinfengge

qinfengge

醉后不知天在水,满船清梦压星河
github

RuoYi-Vue-Plus uses skywalking for distributed tracing.

Recently, I need to perform concurrent testing on the program's interface, and I am not satisfied with the results obtained using jmeter. The main operations are uploading and database query processing, and I want to know the respective time consumption for uploading and database processing. After checking the Ruoyi documentation, I found that it supports skywalking, which makes it easier.

Installation#

To use skywalking, you need to install dependencies, mainly two files, one is the server-side and the other is the agent.
There are also two installation methods, one is to download and install directly, which is more suitable for development environments, and the other is to use docker-compose to deploy with a configuration file.

Direct installation#

Download the files from the official website

image

It is recommended to download an older version of APM, as the latest version may have some issues when starting on Windows.

image

Choose the corresponding agent for your language, in this case, it is Java. You can choose the latest version, but remember to match the version you downloaded when adding the Maven dependency.

After downloading, unzip the files.

After unzipping APM, go to the bin folder and start it.

image

The default web UI uses port 8080. If your port is already occupied, you can modify the webapp\webapp.yml file.

image

If you have any other issues, please check the logs in the logs folder.

Docker startup#

This method is more suitable for deployment in production environments because it adds elasticsearch middleware to process logs.

version: '3'

services:
  elasticsearch:
    image: elasticsearch:7.17.6
    container_name: elasticsearch
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      # Set the cluster name
      cluster.name: elasticsearch
      # Start in single-node mode
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xms512m -Xmx512m"
    volumes:
      - /docker/elk/elasticsearch/plugins:/usr/share/elasticsearch/plugins
      - /docker/elk/elasticsearch/data:/usr/share/elasticsearch/data
      - /docker/elk/elasticsearch/logs:/usr/share/elasticsearch/logs
    network_mode: "host"

  sky-oap:
    image: apache/skywalking-oap-server:8.9.1
    container_name: sky-oap
    ports:
      - "11800:11800"
      - "12800:12800"
    environment:
      JAVA_OPTS: -Xms512m -Xmx1g
      # Record data TTL in days
      SW_CORE_RECORD_DATA_TTL: 7
      # Metrics data TTL in days
      SW_CORE_METRICS_DATA_TTL: 7
      SW_STORAGE: elasticsearch
      SW_STORAGE_ES_CLUSTER_NODES: 127.0.0.1:9200
      TZ: Asia/Shanghai
    network_mode: "host"

  sky-ui:
    image: apache/skywalking-ui:8.9.1
    container_name: sky-ui
    ports:
      - "18080:18080"
    environment:
      SW_OAP_ADDRESS: http://127.0.0.1:12800
      TZ: Asia/Shanghai
      JAVA_OPTS: "-Dserver.port=18080"
    depends_on:
      - sky-oap
    network_mode: "host"

Note: Open the corresponding ports.
Direct startup may result in a failure to start elasticsearch.

Error opening log file 'logs/gc.log': Permission denied

This is because elasticsearch does not have permission to write log files to the corresponding path.
The solution is simple, just grant permission to the corresponding folder.

sudo chmod 777 -R /docker/elk/elasticsearch

After making the changes, restart it and open http://ip:9200 to view the information output by Elasticsearch.

image

Usage#

After the installation is complete, using skywalking in RuoYi-Vue-Plus is also very simple, just uncomment the relevant code.

Uncomment the Maven in ruoyi-admin/pom.xml and set the corresponding downloaded Agent version.

image

Modify the log printing in ruoyi-admin/src/main/resources/logback.xml

image

image

Startup#

Next, inject the Agent when the program starts.

image

Choose to add runtime parameters.

-javaagent:D:\sky\skywalking-agent.jar
-Dskywalking.agent.service_name=ruoyi-auth
-Dskywalking.collector.backend_service=127.0.0.1:11800

The meaning of each parameter is as follows:
javaagent: The location of the downloaded Agent jar file.
service_name: The name of the service.
backend_service: The address of skywalking.

javaagent refers to the jar file inside the downloaded Agent folder.
image

After successful configuration, some logs will be output to the console.

image

Access#

Now you can access the skywalking web UI at http://IP:18080.

image

You can set the language and auto-refresh in the upper right corner.

image

Skywalking Link Monitoring
SpringBoot Integration with SkyWalking 8.X (Including Logback Log Collection)
add Integration of Skywalking, default comment is not enabled
Skywalking Download
SkyWalking Quick Start

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.