Follow me SpringCloud | CHAPTER 15: micro-services (a) Skywalking sword of APM platform

SpringCloud series of tutorials | CHAPTER 15: APM platform sword of micro-services (a) Skywalking

Springboot: 2.1.7.RELEASE

SpringCloud: Greenwich.SR2

1. Skywalking Overview

Skywalking and November 2, 2016 uploaded by the people Wu Sheng in Github v1.0 version, for providing a distributed link tracking, start from 5.x to become a more perfect function of APM (Application Performance Management) system, April 17, 2019 graduated from the Apache incubator, officially became the top-level Apache project. Provide distributed tracking, telemetry service grid analysis, metrics aggregation and visualization integration solutions. The official introduction of their own is designed for micro-services, cloud-based and native vessel (Docker, Kubernetes, Mesos) architecture and design.

2. Skywalking main function

  • Service, service instance, endpoint analysis indicators
  • Root Cause Analysis
  • Service topology analysis
  • Services, service instances and endpoints dependency analysis
  • Slow service detects
  • Performance Optimization
  • Distributed tracking and context propagation
  • Database access indicators detected a slow database access statements (including SQL)
  • Warning

3. Skywalking Key Features

  • A variety of control measures, language and service mesh probe
  • Multilingual automatic probe, Java, .NET Core and Node.JS
  • A variety of back-end storage support
  • Lightweight and efficient
  • Modular, UI, storage, cluster management a variety of optional mechanisms
  • Support alarm
  • Excellent visualization program

4. Skywalking Architecture Overview

Official look at the architecture diagram, as shown:

Skywalking general consists of four parts agent, collector, webapp-ui, storagecomposition. 10-11 from top to bottom is the access application layer, may be used non-invasive agentprobe access, is transmitted to the analysis Skywalking internet data via HTTP or GRPC speaking collector, collectorto analyze the received data for the polymerization, to final storage storagein here supports a variety of storage, more commonly used H2 and elasticSearch, may be the last webapp-uion display for all the data.

5. Spring Cloud and actual Skywalking

5.1 Skywalking build deployment

Before the introduction of actual combat, we briefly explain Skywalking deployment construction scheme.

Here I choose to use storage ElasticSearch, specific version is 6.5.0, ElasticSearch are built Docker choose to use, direct use Linux to build a little more complicated, not suitable for beginners, easy to use Docker building.

It built a number of pre-conditions:

java: 1.8
CentOS: 7.6

If you do not Docker environment on the current CentOS, you can use the following statement to rapidly build:

yum install docker

When the build is successful, you can use the following statement to view the current version Docker:

docker -v

The author here is the output:

Docker version 1.13.1, build 7f2769b/1.13.1

After installing Docker, the best configuration of mirror sites at home, otherwise the situation Docker download fails, etc. may occur when the network is not good, you can use the following statement to modify the mirror address:

vi /etc/docker/daemon.json

I used here is a mirror image of Ali cloud acceleration, as follows:

{
    "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}

You readers can go to their own mirror to accelerate the opening of Ali cloud, not much to do specific description.

Use Docker build ElasticSearch6.5.0, first of all, you need to download the image ElasticSearch6.5.0, enter the following command:

docker pull elasticsearch:6.5.0

Wait for the program download is complete, you can start after the completion of the mirror, the command is as follows:

docker run -d --restart=always --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.5.0

ElasticSearch default startup memory is 1g, if the current server is less than 1g of memory, you can use the parameter -e ES_JAVA_OPTS="-Xms256m -Xmx256m"limit memory size ElasticSearch start and complete statement is as follows:

docker run -d --restart=always -e ES_JAVA_OPTS="-Xms256m -Xmx256m" --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.5.0

After a successful start can use the following statement to see if started successfully:

docker ps

The results are shown:

ElasticSearch6.5.0 single node version has been built, in order to facilitate the subsequent operation, a need to modify the name of ElasticSearch, enter the command docker exec -it es /bin/bashinto the container file directory, input vi config/elasticsearch.ymlinto the ElasticSearch configuration file, modify the cluster.namevalue, where I is modified CollectorDBCluster, the modification is completed, save the current modify, enter exitquit container file directory, enter docker restart esrestart the current container, enter http://192.168.44.128:9200/ in the browser, see the following information may prove ElasticSearch6.5.0 single-node version has been in normal running.

{
  "name" : "V-N2_ZQ",
  "cluster_name" : "CollectorDBCluster",
  "cluster_uuid" : "r9bFZ90WRyqSpMz80u61Yg",
  "version" : {
    "number" : "6.5.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "816e6f6",
    "build_date" : "2018-11-09T18:58:36.352602Z",
    "build_snapshot" : false,
    "lucene_version" : "7.5.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Skywalking build into Skywalking official website, go to the download page ( http://skywalking.apache.org/downloads/ ), as shown:

Because we want to run on CentOS, so here choose Linux binary version is compiled versions, we do not need to compile it yourself, download it to our CentOS, decompression can see the directory structure, as shown:

  • agent: probe related back will do a more detailed description.
  • bin: Here is oapService and webappService put startup scripts, of course, there are two scripts merge script execution startup.sh.
  • config: Here is the major repository of configuration information collector, we need to modify the configuration of application.yml about ElasticSearch here in the following chart:

Modify storage.elasticsearch.nameSpacebuild ElasticSearch set for us earlier cluster.name, the author is here CollectorDBCluster, and modify storage.elasticsearch.clusterNodesas ElasticSearch address our current build.

  • logs: log collector and storage webapp-ui generated.
  • webapp: Here is stored in Skywalking show the UI jar and configuration files.

Skywalking default port used are 8080,11800,12800, please ensure that these ports are not occupied. For changes, you can modify configthe directory application.ymland webappthe directory webapp.yml.

Then start the collector and the webapp-ui, go to the bin directory, execute the command ./startup.sh, such as:

Open a browser to access http://192.168.44.128:8080/, you can see the webapp-ui dashboard, as shown:

Skywalking deployed to end here, let's start with how to introduce Spring Cloud integration Skywalking use.

5.2 Spring Cloud integration Skywalking combat

Briefly explain the case of the contents, we will create four projects, namely Zuul-Service, Eureka-Service, Consumer-Service and Provider-Service, requesting further access to Provider-Service Zuul-Service Access to Consumer-Service by completing a link calls.

Overall architecture is shown in Figure:

Specific implementation code listed, you readers can refer to the GitHub repository ( https://github.com/meteor1993/SpringCloudLearning/tree/master/chapter15 ), here we introduce how to Skywalking Spring Cloud integration.

Here we need to use to probe agent Skywalking, we are in a new project with the chapter15 directory in a folder named skywalking, say just extracted Skywalking the agent to copy the entire folder skywalking, there need only configure command when we start javaagen load agent probes can, using the idea of the need to modify the boot configuration, click the upper right corner Edit Configurations..., in the window that opens select Environment->VM Options, configure the following script:

-javaagent:D:\Development\SpringCloudLearning\chapter15\skywalking\agent\skywalking-agent.jar
-Dskywalking.agent.service_name=zuul-service
-Dskywalking.collector.backend_service=192.168.44.128:11800

Figure:

You can also use java -jar way to load agent probe, we will pack the entire maven project, run mvn install command, using java -jar way to start, start-up command to increase startup parameters, as follows:

-javaagent:D:\Development\SpringCloudLearning\chapter15\skywalking\agent\skywalking-agent.jar -Dskywalking.agent.service_name=consumer-service -Dskywalking.collector.backend_service=192.168.44.128:11800 -jar zuul-0.0.1-SNAPSHOT.jar

After four sequential start projects, using a browser to access: HTTP: // localhost: 8080 / Client / = the Hello name the Spring, after refresh a few times, we use a web browser to access http://192.168.44.128:8080? /, such as :

  • all_heatmap: All hot FIG service response time
  • all_p99: All service response time value of p99

Click on the top bar of the topology map, you can see the current rely on our project a topological relationship, such as:

Click tracking top bar, you can see on the left is all the current access request, just a click, you can see a detailed link on the right track process, such as:

Click on the link, you can see some tag information, inclusive, span type, success or failure, as well as some of the Exception information, as shown:

Click on the dashboard page of Service, you can see some of the service-related information, such as average response time, average throughput, average latency statistics as:

  • service_instance_sla: the success rate of the service instance
  • The average response time for service instance: service_instance_resp_time
  • service_instance_cpm: service instance calls per minute

Click on the dashboard page Endpoint, you can see some endpoint-related information, as shown:

  • endpoint_cpm: Endpoint per minute calls
  • endpoint_avg: Endpoint average response time
  • endpoint_sla: endpoint success rate
  • endpoint_p99: end time value in response to p99

Click Instance dashboard page, you can see some information related to the JVM, as shown:

So far, Spring Cloud and Skywalking introduction is over, interested friends can go to the official website Github query.

6. Summary

Here to sum up the boot sequence the entire case:

  1. Start ElasticSearch
  2. Start collector
  3. Start web-ui (or using an integrated script starts)
  4. Start Agent (Eureka, provider, consumer, zuul)
  5. Application calls
  6. Access web-ui view statistics

Above the boot sequence reference for our readers, please readers to the best start in the above order, because in fact there are interdependencies of the different components before, if free to change the boot order may cause some unknown problem.

Guess you like

Origin www.cnblogs.com/babycomeon/p/11416108.html