Why SkyWalking?
Skywalking is an excellent APM (application performance monitor) application performance monitoring system. It is designed for micro-service scenarios and can easily implement performance monitoring and link tracking in micro-service scenarios such as Spring cloud.
The v8.x version also supports the log collection function, which can replace ELK as a distributed log collection solution. One system realizes multiple capabilities of 监控+追踪+日志
, effectively reducing the complexity of operation and maintenance under microservices.
Let's take Spring cloud as an example to play Skywalking together
1. Environment preparation and installation
To implement 监控+追踪+日志
we need to install basic APM and Java agent.
- Go to the download page: SkyWalking Download
- Download
SkyWalking APM
andJava agent
following two zip files:
- After downloading, unzip it and try to run
/apache-skywalking-apm-bin/bin/startup.bat
(orstartup.sh
) - Visit http://localhost:8080/ to see the SkyWalking monitoring UI
The above installation is a direct installation. For installation methods such as docker, please refer to the official SkyWalking documentation
2. Configure SkyWalking log collection (logback as an example)
The logback plugin package that depends on SkyWalking in the pom:
<!-- SkyWalking log collection --> <dependency> <groupId>org.apache.skywalking</groupId> <artifactId>apm-toolkit-logback-1.x</artifactId> <version>8.9.0</version> </dependency>
Add/modify logback.xml to enable the appender provided by SkyWalking. The sample configuration is as follows:
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="10 seconds"> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout"> <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%tid] [%thread] %-5level %logger{36} -%msg%n</Pattern> </layout> </encoder> </appender> <appender name="grpc" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender"> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout"> <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n</Pattern> </layout> </encoder> </appender> <root level="INFO"> <appender-ref ref="stdout"/> <appender-ref ref="grpc"/> </root> </configuration>
3. Configure the Java agent
Configure the Java agent in the IDEA development environment:
Open the
Edit Run/Debug Configurations
of each service application and add the following VM options:-javaagent:D:/Server/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=yourAppName -Dskywalking.collector.backend_service=localhost:11800
Configure the Java agent in the production environment:
Tomcat server configuration and the configuration method to run with
java -jar
: For details, please refer to the official SkyWalking Java agent configuration document
4. Start each service application under the microservice
Then enter your spring cloud microservice front-end UI to do some operations to verify monitoring and logs.
5. Access the SkyWalking UI console http://localhost:8080/
- Example of performance monitoring effect (which interface should be optimized is clear):
- Example of link tracking effect (slow is also seen in which link):
- Example of log collection effect:
Note: By default, SkyWalking uses H2 database storage, and does not support full-text search to check log content. It is recommended to switch to ElasticSearch storage for the production environment.
Diboot - A low-code development framework written with less performance and better
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。