Recently, I need to perform concurrent testing on the program's interface, and I'm not satisfied with the results 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 the dependencies, which mainly include two files: one is the server-side and the other is the agent.
There are two ways to install: one is to download and install directly, which is more suitable for development environments; the other is to use docker-compose to deploy with a configuration file.
Direct Installation#
Download the files from the official website
It is recommended to download an older version of APM, as the latest version may have some issues with Windows startup.
Choose the corresponding language for the agent, which is Java in this case. You can choose the latest version, but remember to match the version you downloaded when adding the Maven dependency.
After downloading, extract the files.
After extracting APM, go to the bin
folder and start it.
The default web UI uses port 8080. If your port is already occupied, you can modify the webapp\webapp.yml
file.
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 that you need to open the corresponding ports.
Direct startup may result in a failure to start elasticsearch
with the following error:
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 give the corresponding folder the necessary permissions:
sudo chmod 777 -R /docker/elk/elasticsearch
After making the changes, restart the service and open http://ip:9200
to check the output information from Elasticsearch.
Usage#
After installation, using skywalking in RuoYi-Vue-Plus is quite simple. You just need to uncomment the relevant code.
Uncomment the Maven configuration in ruoyi-admin/pom.xml
and set the corresponding Agent version.
Modify the log printing in ruoyi-admin/src/main/resources/logback.xml
Startup#
Inject the Agent when starting the program.
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 meanings of the parameters are as follows:
javaagent
: The location of the downloaded Agent jar file.
service_name
: The service name.
backend_service
: The address of skywalking.
javaagent
refers to the jar file inside the extracted Agent folder.
After successful configuration, some logs will be output to the console.
Access#
Now you can access the skywalking web UI at http://IP:18080
.
You can set the language and auto-refresh in the upper right corner.
Skywalking Link Monitoring
SpringBoot Integration with SkyWalking 8.X (Including Logback Log Collection)
Add Integration with Skywalking, Default Comment Not Enabled
Skywalking Download
SkyWalking Quick Start