What is Skywalking
Skywalking is a performance monitoring tool for distributed systems
Document address:https://skyapm.github.io/document-cn-translation-of-skywalking/
Function:
- Services, service instances, endpoint metric analysis
- Root Cause Analysis
- Service topology diagram analysis
- Services, service instances and endpoint dependency analysis
- Slow services and endpoints detected
- Performance optimization
- Distributed tracing and context propagation
- Database access metrics
- Alarm
Install the stand-alone version of Skywalking
download
- Go tohttps://archive.apache.org/dist/skywalking/6.6.0/ and download according to your operating system That’s it.
It is recommended to use the same version as me. Currently, Skywalking is still in a relatively active development state. Different versions perform differently, so it is best to stay consistent with me to avoid stepping on unnecessary pitfalls.
environmental needs
- The JDK version is between JDK8-JDK12
- Note that if you use ElasticSearch7 version, you need JDK11+
- Make sure the following ports are available:
- 11800: gRPC port for communicating with Skywalking
- 12800: HTTP port for communicating with Skywalking
- 8080: The port occupied by the UI
You can use the following command to check whether the port is occupied
#Linux/macOs netstat -an|grep 8080 #对于使用windows的同学,可以使用 netstat -ano|findstr 8080
If there is no result, it means that port 8080 is not occupied, and the same is true for other ports.
Installation & Startup
Installing Skywaling is relatively simple, just unzip it and then execute the corresponding command depending on the operating system.
Linux or macOS
implement:
cd apache-skywalking-apm-bin/bin
sh startup.sh
Windows
implement:
cd apache-skywalking-apm-bin/bin
startup.bat
After we start, seeing this message means that the startup is successful.
If you do not start successfully, you can switch to the logs directory to view the log details.
After successful startup, we visitlocalhost:8080
:
Skywalking has been built, so how do we use it?
I also wrote some notes on how to use it, let’s take a look:
Skywaking use
This document is written based on Skywalking6.6.0, and theoretically supports all versions of Skywalking6.0+
This article explores how to use Skywalking monitoring applications.
There are many ways to use Skywalking. The most popular (and most powerful) way to use it is based on Java agent.
Configure java agent
- Find the
agent
directory in the SkyWaking package - Copy the
agent
directory to any location - Configuration
config/agent.config
- Change
agent.service_name
to your microservice name: - If Skywalking and microservices are deployed on different servers, you also need to modify the value of collector.backend_service. This configuration is used to specify the communication address between microservices and Skywalking. The default is
127.0.0.1:11800
. Press Just need to modify it. Of courseagent.config
there are many configurations in the file. You can check the official documentation for specific configurations.
- Change
We copied the agent directory to the desktop, and then modified agent.service_name to the name of our own service:
Start application
java -jar
Start the application
For example, if there is a Spring Boot application, after modifying the agent
directory:
- Execute the following command to start:
# 注意-javaagent必须在-jar之前 java -javaagent:/Users/weichenglong/Desktop/agent/skywalking-agent.jar -jar aym-api.jar
- If you start the test in the IDE, refer to the configuration below and then start it.
After we start the project, we can perform some tests by calling the project's Rest API. Here I used a plug-in from IDEA, RestfulTool:
After installation, it can automatically identify all APIs in the current project:
Through this plug-in, we can access several interfaces at will:
Then, we enter the page again, click refresh in the upper right corner, and then we can see the following information:
The cpm of the project is displayed on the page, and cpm can be used to a certain extent. Reflects the throughput or number of concurrency of the current application
and can also display the slowest endpoints.
Here are the statistics corresponding to the API response time:
The second is the database view:
It can display some statistical information of the database, such as the average response time, throughput, service quality, response time, etc. of the database.
Generally speaking, we will pay more attention to the statistical values of database response time, throughput and response time, and the most concerned about the slowest APIs in the project.
Click on the topology map
Here you can see where the user's request goes.
This picture is still very meaningful. For developers, they can check the location of each service. For architects, it can also help them check whether the implementation of the current project is consistent with his plan. .
Clicking on the service can also display some details and list some performance indicators, such as response time, cpm, etc.
Click tracking:
This is the most important navigation in the entire Skywalking. This page can display in detail which APIs of the specified application have been accessed, how long it took in total, and how long each How long does the API take at each stage?
For example:
/products This API took a total of 8871 milliseconds.
Among them:
5980 milliseconds were spent on SpringMVC.
Click us to view details:
We can see the accessed database information and the executed sql. Here is a sql for mysql repeatability verification.
Look below:
This is the SQL that actually executes the business.
The last one is commit:
Here you can see at a glance how long each stage takes.
Once we find that our application performance does not meet the requirements, we can track which APIs are taking too long by tracking the far left side of the page.
Through the right side, you can analyze which part of these APIs takes too long, whether it is slow API execution or slow database access, which can be quickly analyzed.
In this way, when we locate performance bottlenecks, we can be targeted.
At the same time, Skywalking also has the ability to compare alarms and indicators:
It is not difficult to find that the function of Skylking is still very powerful.