What is link monitoring
APM
What is a link
In distributed systems, many services collaborate to complete a function, and the requests to connect these services combine as links.
For example, if I want a bicycle to run, I have to use a chain, so the chain is a link.
What is link monitoring
It is used to record the request process between services, that is, link monitoring
Why use link monitoring
As shown in the figure, microservices do not use link monitoring
1. The microservice system runs normally and the monitoring center is not needed under normal time conditions
2. Time consuming in the process of microservice invocation
2.1 How can I know the cause of time consumption and find out which node is faulty
3. What microservice situations are involved in the process of microservice invocation
3.1 It is impossible to know the invocation process of microservices.
In the case of these two problems, we therefore need to use the time required to know the call process between microservices and the call process for each microservice.
Based on the problems in the scenario, link monitoring is introduced
So how to solve these two kinds of problems, so there is link monitoring
Link monitoring framework
Cat: Developed by Dianping, it is a Real-time application monitoring platform based on Java, including real-time application monitoring and its business is monitoring
Zipkin is an open source call chain analysis tool of Twitter. Currently, Zipkin is widely used based on SpringCloud SleUTH. It is characterized by light weight and simple deployment: strong code embedment, implemented based on middleware,
Pinpoint e is the Korean open source based on bytecode injection call chain analysis, as well as application monitoring analysis tools. Feature is to support a variety of plug-ins, UI powerful, access end without code intrusion
SkyWalking: Java development SkyWalking is a native open source call chain analysis and application monitoring analysis tool based on bytecode injection. Feature is to support a variety of plug-ins, strong UI function, access end without code intrusion. You have joined the Apache incubator. Full link tracing, extremely simple configuration. There was no code intrusion.
Naver Pinpoint, Apache HTrace, Ali Eagle Eye Tracing, Jingdong Hydra, Sina Watchman, Meituan Dianping CAT, Skywalking, etc.
Conclusions are drawn based on comparisons of advantages and disadvantages (also some configurations and comparisons within the framework)
1. The two aspects should be combined with the characteristics of the framework and the business scene
So we chose SkyWalking
How to use SkyWalking in microservices
SkyWalking concept
Skywalking Agent
SkyWalking client that sends link data to Collecter
SkyWalking Collecter
Analyze, process, and store link data to storage
Skywalking Storage
The analyzed link result data is stored
SkyWalking UI
Display link data for easy monitoring
SkyWalking integration schematic
See the picture for demonstration
How to use SkyWalking
conditions
1, JDK1.8
2, Elasticsearch 6.6.0
3, SkyWalking
4, SkyAPM – dotnet
5. API gateway
steps
1. JDK 1.8 operation
1.1 jdk1.8 download
Downloaded already
Elasticsearch 6.6.0
2.1 Elasticsearch 6.6.0 download
Download address: www.elastic.co/cn/download…
2.2 Elasticsearch 6.6.0 Configuration
Elasticsearch. Yml in the elasticSearch -6.6.0/config directory
Net. host: 0.0.0.0 Adds thread_pool.bulk.queue_size: 1000Copy the code
2.3 Elasticsearch 6.6.0 enabled
After the package is decompressed, double-click elasticSearch -6.6.0/bin to start it
elasticsearch.bat
Copy the code
2.4 Elasticsearch 6.6.0 Access
Enter access address :http://localhost:9200. The page is displayed. The installation is successful
3. SkyWalking operation
3.1 SkyWalking download
Download address: skywalking.apache.org/downloads/
3.2 SkyWalking configuration
After decompressing, go to apache-Skywalk-apm-bin /config and configure it in application.yml
elasticsearch: nameSpace: ${SW_NAMESPACE:""} clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"} trustStorePath: ${SW_SW_STORAGE_ES_SSL_JKS_PATH:".. /es_keystore.jks"} trustStorePass: ${SW_SW_STORAGE_ES_SSL_JKS_PASS:""} user: ${SW_ES_USER:""} password: ${SW_ES_PASSWORD:""} indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2} indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0} # Those data TTL settings will override the same settings in core module. recordDataTTL: ${SW_STORAGE_ES_RECORD_DATA_TTL:7} # Unit is day otherMetricsDataTTL: ${SW_STORAGE_ES_OTHER_METRIC_DATA_TTL:45} # Unit is day monthMetricsDataTTL: ${SW_STORAGE_ES_MONTH_METRIC_DATA_TTL:18} # Unit is month # Batch process setting, Refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:1000} # Execute the bulk every 1000 requests flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}Copy the code
Annotation configuration
# h2:
# driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
# url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
# user: ${SW_STORAGE_H2_USER:sa}
# metadataQueryMaxSize: ${SW_STORAGE_H2_QUERY_MAX_SIZE:5000}
Copy the code
3.3 SkyWalking webapp configuration
Switch to apache-Skywalk-apm-bin /webapp directory and configure in webapp.yml
server:
port: 8081
Copy the code
3.4 SkyWalking start
After decompressing the file, double-click apache-Skywalk-apm-bin /bin to start the file
startup.bat
Copy the code
3.4 SkyWalking
Enter the address: http://localhost:8081. The installation is successful
4. Skyapm-dotnet operation
4.1 SkyAPM – dotnet download
Source code address: github.com/SkyAPM/SkyA…
5. Api gateway
5.1 Api Gateway Installation
In RuanMou. MicroService. Gateway project, Nuget install
Nuget SkyAPM.Agent.AspNetCore
Nuget System.Data.SqlClient
Copy the code
5.2 Api Gateway Configuration
5.2.1 in RuanMou. MicroService. Gateway project, create
skyapm.json
Copy the code
5.2.2 Add in the Skyapm. json file
{
"SkyWalking": {
"ServiceName": "AggregateService"."Transport": {
"gRPC": {
"Servers": "localhost:11800"}}}}Copy the code
5.2.3 requires in RuanMou. MicroService. Gateway project launchSettings. Json file, configuration
"environmentVariables": {
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore"
}
Copy the code
5.2.4 start RuanMou. MicroService. Gateway for a visit
Enter the gateway address
http://localhost:5004:/AggregateService/api/teams
5.2.5 Starting the Link Monitoring Center
You can view monitoring information