SkyWalking Guide: Setup, Tracing, Logging & Alerts for Distributed Apps
This article walks through SkyWalking, an open‑source APM solution, covering its architecture, server and client installation, configuration for MySQL persistence, log collection, performance profiling, and alerting, while comparing it with Spring Cloud Sleuth + Zipkin and showing practical code examples.
What Is SkyWalking?
SkyWalking is an open‑source APM framework from China, started in 2015 by a Huawei developer and entered the Apache incubator in 2017. It supports Dubbo, Spring Cloud, and Spring Boot, uses bytecode enhancement for non‑intrusive instrumentation, communicates via gRPC, and provides alerting, JVM monitoring, and global call statistics.
Choosing SkyWalking vs. Spring Cloud Sleuth + Zipkin
SkyWalking offers non‑intrusive bytecode enhancement, richer UI and reporting, while Zipkin requires more code changes. For new architectures, SkyWalking is recommended.
SkyWalking Architecture
Similar to Zipkin, SkyWalking consists of four parts: the Agent (collects logs), the OAP server (analysis, storage, query), the UI (web console), and the Storage component (supports multiple backends).
Server Setup
1. Download the Package
Select version V8.7.0 and unzip the archive.
Key directories after extraction:
agent : contains the jar for instrumentation.
bin : startup scripts for OAP and UI services.
config : configuration files.
logs : OAP service logs.
oap-libs : OAP dependencies.
webapp : UI service files.
2. Modify Configuration
Update /config/application.yml to use Nacos as the registry and adjust Nacos settings as needed.
Change the UI port in webapp/webapp.yml from the default 8080 to 8888 to avoid conflicts.
3. Start Services
Run the scripts in the /bin directory: oapService.bat (or .sh) for the OAP server and webappService.bat (or .sh) for the UI. You can also use startup.bat to launch both at once.
After startup, access the UI at http://localhost:8888/.
Client Setup
Because SkyWalking uses bytecode enhancement, no code changes are required for microservices. Add the agent jar to the JVM launch command:
-javaagent:E:\springcloud\apache-skywalking-apm-es7-8.7.0\apache-skywalking-apm-bin-es7\agent\skywalking-agent.jar
-Dskywalking.agent.service_name=skywalking-product-service
-Dskywalking.collector.backend_service=127.0.0.1:11800Explanation:
-javaagent : path to skywalking-agent.jar.
-Dskywalking.agent.service_name : sets the service name (usually the Spring application name).
-Dskywalking.collector.backend_service : address of the OAP server (default 11800).
These parameters can also be set in the IDE run configuration.
Data Persistence
By default SkyWalking stores tracing data in memory, which is lost after a restart. To persist data, modify config/application.yml to use MySQL (or Elasticsearch). Change the storage type to mysql and set the MySQL connection details.
Place the MySQL JDBC driver jar into the oap-libs directory.
Log Monitoring
SkyWalking provides a log module. To forward logs, add the appropriate toolkit dependency (e.g., apm-toolkit-logback-1.x) and configure logback-spring.xml as shown in the official documentation.
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-logback-1.x</artifactId>
<version>${project.release.version}</version>
</dependency>After starting the services, logs with trace IDs appear in the UI.
Performance Profiling
Create a profiling task in the UI, select the service and endpoint (e.g., {GET}/order/list), and run the endpoint several times. SkyWalking will display stack traces and highlight the slow code (e.g., a 2‑second Thread.sleep).
Alerting
SkyWalking includes default alert rules (e.g., average response time > 1 s over 3 min). Rules are defined in config/alarm-settings.yml. Custom webhooks can be added to send notifications via email, WeChat, or DingTalk.
After configuring a webhook, triggering the rule (e.g., by repeatedly calling the 2‑second endpoint) will send alerts and log them.
Summary
This article introduced SkyWalking as a distributed tracing solution, covering server and client setup, data persistence, log monitoring, performance profiling, and alerting, each of which is essential for observability in modern microservice architectures.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
