With the popularity of micro service architecture, especially SpringCloud is widely used in recent years, some problems are more prominent under the service architecture, such as a request will involve multiple services, and the service itself may also depend on other services, the entire request path will form a network of invocation chain, and an exception occurs when a node in the call chain, The stability of the entire call chain will be affected. In order to quickly locate and solve the problem, we need a set of tools that can track and analyze system performance, namely APM (Application performance management).

At present, the mainstream APM tools are Skywalking, Cat, Zipkin, Pinpoint, this paper mainly introduces Skywalking, it is an excellent domestic APM tool, including distributed tracking, performance index analysis, application and service dependency analysis.

The official architecture diagram is shown below

Set up the deployment

The following is a brief introduction to the installation and deployment of Skywalking on Mac

download

Select the appropriate version from the official address to download

Unpack the installation

The decompressed directory is as follows

├ ─ ─ agent / / local agent module (probe) │ ├ ─ ─ activations │ ├ ─ ─ the bootstrap - plugins │ ├ ─ ─ the config │ ├ ─ ─ logs │ ├ ─ ─ optional - plugins │ └ ─ ─ Plugins ├ ─ ─ bin / / startup scripts ├ ─ ─ the config / / data collector, storage, the alarm configuration ├ ─ ─ licenses │ └ ─ ─ the UI - licenses ├ ─ ─ logs ├ ─ ─ mesh - buffer ├ ─ ─ ├── imp ├─ oap-Heavy Exercises ── imp ├── Imp ├─ Oap-heavy Exercises ── Imp ├─ Run startup.sh in the bin directory to start the service. After the service is started, the following information is displayed: hee ' 'bash./startup.sh SkyWalking OAP started successfully! SkyWalking Web Application started successfully!Copy the code

You can then view the SkywalkingUI interface by visiting http://localhost:8080/

After startup, two services, Skywalk-WebApp and Skywalk-Collector, are started

  1. Skywalking – Webapp, management platform page, default port 8080(can be changed in webapp/webapp.yml), user name and password admin/admin
  2. Skywalk-collector: collect client information via gRPC or HTTP (default gRPC port 11800, default HTTP port 12800)

The configuration of collector, storage, and collectable information can be modified under config/application.yml

Java process use

  • IDEA, added in VM Options
- javaagent: / path/to/skywalking - agent/skywalking - agent. The jar - Dskywalking. Agent. The service_name = service name - Dskywalking. Collector. Backend_service = 127.0.0.1:12800Copy the code

– javaagent skywalking – agent. The absolute position of the jar – Dskywalking. Agent. The service_name, Defined in the UI displays the names of the service (omitted) – Dskywalking. Collector. Backend_service, collect the server address (can be omitted)

  • The jar command is used in the same way as IDEA

Commonly used configuration

You can modify related configurations in config/application.yml

Deployment way

cluster:
  selector: ${SW_CLUSTER:standalone}
  standalone:
Copy the code

Standalon is available for PCS. Cluster deployment also supports ZooKeeper, Kubernetes, Consul, ETCD, Nacos, etc

Configure the information collection protocol

core:
  selector: ${SW_CORE:default}
  default:
    # Mixed: Receive agent data, Level 1 aggregate, Level 2 aggregate
    # Receiver: Receive agent data, Level 1 aggregate
    # Aggregator: Level 2 aggregate
    role: ${SW_CORE_ROLE:Mixed} # Mixed/Receiver/Aggregator
    restHost: The ${SW_CORE_REST_HOST: 0.0.0.0}
    restPort: ${SW_CORE_REST_PORT:12800}
    restContextPath: ${SW_CORE_REST_CONTEXT_PATH:/}
    gRPCHost: The ${SW_CORE_GRPC_HOST: 0.0.0.0}
    gRPCPort: ${SW_CORE_GRPC_PORT:11800}
    gRPCSslEnabled: ${SW_CORE_GRPC_SSL_ENABLED:false}
    gRPCSslKeyPath: ${SW_CORE_GRPC_SSL_KEY_PATH:""}
    gRPCSslCertChainPath: ${SW_CORE_GRPC_SSL_CERT_CHAIN_PATH:""}
    gRPCSslTrustedCAPath: ${SW_CORE_GRPC_SSL_TRUSTED_CA_PATH:""}
Copy the code

RestPort and gRPCPort Set HTTP and gRPC ports respectively. You are advised to use the default values

Storage configuration

storage:
  selector: ${SW_STORAGE:h2}
  elasticsearch:
    nameSpace: ${SW_NAMESPACE:""}
Copy the code

The default is H2 (does not require any other installation and deployment), it can also support ES, mysql, etc. ES is officially recommended, and other storage such as TiDB can also be added

Webapp configuration

Webapp Configuration default location webapp/webapp.yml

server:
  port: 8080

collector:
  path: /graphql
  ribbon:
    ReadTimeout: 10000
    # Point to all backend's restHost:restPort, split by ,
    listOfServers: 127.0. 01.: 12800
Copy the code

The default port of the management background is 8080. The default port of the oAP data collection using graphQL is 12800 (REST).

The agent configuration

Agent configuration by default in the agent/config/agent. The config

# Different namespaces cause call link tracing to break
agent.namespace=${SW_AGENT_NAMESPACE:hmall}

# page shows the name of the service, can also pass - Dskywalking. Agent. The service_name = XXX specified
agent.service_name=${SW_AGENT_NAME:gateway}

# platform invoke the address, but can be by - Dskywalking. Collector. Backend_service = 127.0.0.1:80 specified
The collector. Backend_service = ${11800} SW_AGENT_COLLECTOR_BACKEND_SERVICES: 172.28.51.141:

# ignore collection of requests with the specified suffix
agent.ignore_suffix=${SW_AGENT_IGNORE_SUFFIX:.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg}


# Sampling rate per 3 seconds, negative numbers represent 100%
agent.sample_n_per_3_secs=${SW_AGENT_SAMPLE:-1}
Copy the code

The plug-in USES

By default, agent does not support the monitoring of spring-cloud-gateway, requiring plug-in support. Apm-spring-cloud-gateway-2.x -plugin-7.0.0.jar (apM-spring-cloud-gateway-2.x -plugin-7.0.0.jar) The same goes for other middleware and frameworks that require additional plug-in support.

reference

Apache Skywalking Skywalking Distributed tracking system Overview of Skywalking tracking in a full link