Build Skywalking step by step and play with distributed link tracking

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

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.
Insert image description here
If you do not start successfully, you can switch to the logs directory to view the log details.

After successful startup, we visitlocalhost:8080:Insert image description here

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 theagentdirectory in the SkyWaking package
  • Copy the agent directory to any location
  • Configurationconfig/agent.config
    • Changeagent.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 is127.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.

We copied the agent directory to the desktop, and then modified agent.service_name to the name of our own service:
Insert image description here

Start application

java -jarStart 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.
    Insert image description here

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:
Insert image description here

After installation, it can automatically identify all APIs in the current project:
Insert image description here

Through this plug-in, we can access several interfaces at will:
Insert image description here

Then, we enter the page again, click refresh in the upper right corner, and then we can see the following information:Insert image description here
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:
Insert image description here

The second is the database view:
Insert image description here
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 mapInsert image description here
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. .

Insert image description here
Clicking on the service can also display some details and list some performance indicators, such as response time, cpm, etc.

Click tracking:
Insert image description here
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:
Insert image description here
/products This API took a total of 8871 milliseconds.

Among them:
Insert image description here
5980 milliseconds were spent on SpringMVC.

Click us to view details:
Insert image description here
We can see the accessed database information and the executed sql. Here is a sql for mysql repeatability verification.

Look below:
Insert image description here
This is the SQL that actually executes the business.

The last one is commit:
Insert image description here

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:
Insert image description here

It is not difficult to find that the function of Skylking is still very powerful.

Guess you like

Origin blog.csdn.net/qq_45455361/article/details/121524992