This is the fifth day of my participation in the More Text Challenge. For details, see:More article challenges

Set up a Flag and write something every day and stick to it.

SkyWalking distributed system tracking

Liverpoolfc.tv: skywalking.apache.org/

Jane: www.jianshu.com/p/2fd56627a…

Documents: skywalking.apache.org/docs/

SkyWalking, it is an excellent domestic APM (Application Performance Management) tool

SkyWalking 8.x

Tar package download: Skywalking.apache.org/downloads/ SkyWalking APM Distribution selection version v8.5.0 for H2 / MySQL/TiDB/InfluxDB/ElasticSearch 7

Yml OAPServerStartUp configuration file config/application.yml Default storage is H2. Change the storage to ELASticSearch7 and ES7 service address. Skywalking – webApp configuration file webapp/webapp. Yml Default port localhost:8080

selector: ${SW_STORAGE:elasticsearch7}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
Copy the code

Installation bin directory

./startup.sh
Copy the code

Visit the UI localhost: 8080

Start the collection end by modifying the startup script in java-jar mode

Java Agent technology principle and simple implementation

nohup java -javaagent:/data/skywalking/apache-skywalking-apm-bin-es7/agent/skywalking-agent.jar -
Dskywalking.agent.service_name=${SERVER_NAME}- Dskywalking. Collector. Backend_service = 127.0.0.1:11800 - jar - Xms1024m - Xmx1024m - Djava. Security. Or egd = file: / dev /. / urandom$JAR_FILE --spring.application.
name=${SERVER_NAME} --spring.profiles.active=${ACTIVE} --server.port=${PORT}> /data/logs/${SERVER_NAME}
/console.log 2>&1&
Copy the code

Idea, modify VM options, as shown in the following example

- DSW_AGENT_NAME = skywalking - consumer # # - DSW_AGENT_COLLECTOR_BACKEND_SERVICES = 127.0.0.1:11800 # # -javaagent:~\skywalking\apache-skywalking-apm-bin-es7\agent\skywalking-agent. jar ##agentCopy the code

[%traceId] was added to print traceId in logs.

<dependency>
    <groupId>org.apache.skywalking</groupId>
    <artifactId>apm-toolkit-logback-1.x</artifactId>
    <version>8.5.0</version>
</dependency>
Copy the code

Modify the Appender Pattern in logback. XML

<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
    <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level logger_name:%logger{36} - [%tid] - message:%msg%n</pattern>
    </layout>
</encoder>
Copy the code

The output log

After adding feign to the project, check the relationship between the calls and the time consuming of each link

Kibana looked at ES, there were a lot of data recorded in ES

At this point, link tracing, performance detection and log query are completed.

Extra: Docker installation

Docker pull apache/skywalking - oap - server: 8.5.0 - es7Copy the code
docker run --name skywalking --net esnet -d -e SW_STORAGE=elasticsearch7 \ -e SW_STORAGE_ES_CLUSTER_NODES=localhost:9200 Apache/skywalking - oap - server: 8.5.0 - es7Copy the code

Conclusion:

Skywalking can implement link tracing in a low-intrusion way through the agent. Link tracing is an important part of microservice governance and an important tool for log query, system monitoring and performance analysis.