Simple and fast completion of distributed system monitoring;

As the mainstream selection of the current system architecture, microservices can cope with complex business scenarios, but with the expansion of services, the complexity of the microservice architecture itself will also expand, for some core business processes, its request link will involve multiple business services, as few as three or five, more than a dozen are very common:

The real business scenario is far more complex than the diagram, in this mode, when the request fails, or when optimization, it is necessary to analyze the link performance, trace the call link, and troubleshoot and solve the link failure.

To complete the above process, it is necessary to have complete monitoring of the requested link, and collect and analyze the data of each link, so as to clearly understand the behavior information of the system, such as time-consuming analysis, fault cause discovery, so as to optimize and solve; There are many components that can achieve this ability, here is a look at the practice based on SkyWalking9;

Skywalking is a domestic open source distributed link tracing system of APM specification, APM (Application-Performance-Management) is application performance management, supports integration of SpringCloud microservices, and has no code-level intrusion:

Structural system

Business mechanism

SpringCloud: a service in a distributed system that can be configured with a proxy at startup;

Agent: Collects data from the request link in the form of a probe and reports it to the management service;

OAP-Service: receive data, complete data storage and display;

Storage: The storage layer of data, supporting ElasticSearch, Mysql, H2 and other ways;

UI interface: visual display interface of data;

Workflow, the service through the probe access to the data acquisition function, and then the relevant processing behavior of the request link will be reported to the OAP service, data aggregation management and analysis, and stored in the persistence layer, and then can be visualized through the UI interface;

1. Version description

skywalking In the previous old version, apm and agent are in a package, in the 9.0 version is required to download separately; after the agent package is downloaded and unzipped, it is also placed under the apm package for maintenance:

2. Configure the storage mode

Skywalking data storage components have a variety of selection methods, here is convenient for local debugging, choose MySQL database, in the production environment usually choose ElasticSearch components;

Configuration file: config/application.yml

It should be noted that to create a new swtest database in local MySQL, using latin1 character encoding, you can avoid the problem of index length, the creation of the table is automatic, and then you need to add MySQL dependencies in the package;

3. Start and stop

UI interface service defaults to port 8080, if there is a problem with occupation, you can modify: webapp/webapp.yml file, change the port; after boot is complete, access LocalIP:port;

4. Service integration

There are three services in the local gateway, facade, account, three services, the case revolves around the request in the account service, because the gateway service is involved, it is also necessary to add the dependency of the relevant plugin;

Copy the dependency packages of the two gateways in the optional-plugins directory to the plugins plugin directory;

Add agent configuration in the service startup class, if in the production environment, usually set uniformly in the script, due to the presentation in the local environment, based on the IDEA tool for management;

So that all the configuration is completed, start the skywalking related services in turn, and the three microservices configured here, let’s take a look at the functional details;

1. Service monitoring

After the relevant service is started, visit the skywalking interface, and the home page loads the three microservices configured above, which means that the whole process is normal, and click on the service name to view the details of the service;

2. Topology structure diagram

The request passes through the gateway service, passes through the facade façade service, reaches the account business service, and after completing a call, view the topology structure diagram of the request (that is, the topology column);

You can clearly see the routing link of the request, as well as the database address accessed by the related services, for the complex interface in the microservice architecture, with the help of the topology model, you can quickly understand the business logic, and at the same time save a lot of drawing time when issuing documents;

3. Link tracking

The above is only the topology structure diagram of the request, in practical applications, it is still more focused on link tracking, view the account service request link (that is, the Trace column);

Skywalking component for development, the most commonly used is the function, here the collection of the request link on the various nodes, as well as the execution of time-consuming analysis, click on the relevant nodes can view the details, for the exception request can also collect the description of the exception information;

This can greatly improve the efficiency of problem troubleshooting, especially for the kind of business logic that routes more than ten services;

4. Database monitoring

Although the monitoring of MySQL is not explicitly added in the entire configuration, skywalking can still implement database monitoring in the service, and the details of these indicators are not too described, and you can consult the documentation by yourself;

This article is only from the perspective of development, summarizing the application of skywalking, does not involve too many details of the principle, other powerful function design, for the development of the same worthy reference.