Skywalking实战教程,全链路追踪神器!
SkyWalking 是观察性分析平台和应用性能管理系统。
提供分布式追踪、服务网格遥测分析、度量聚合和可视化一体化解决方案。
架构:
安装下载部署
1、下载
地址:http://skywalking.apache.org/zh/downloads/
2、安装
下载解压后目录如下:
不需要修改配置文件,在bin目录下执行startup.bat或startup.sh即可启动服务:
执行startup.bat之后会启动如下两个服务:
-
Skywalking-Collector:
追踪信息收集器,通过 gRPC/Http 收集客户端的采集信息 ,Http默认端口 12800,gRPC默认端口 11800。
-
Skywalking-Webapp:
管理平台页面 默认端口 8080,登录信息 admin/admin
3、配置信息
(1)收集器相关配置:支持 http/gRPC收集
1 core: 2 3 default: 4 5 restHost: ${SW_CORE_REST_HOST:0.0.0.0} 6 7 restPort: ${SW_CORE_REST_PORT:12800} 8 9 restContextPath: ${SW_CORE_REST_CONTEXT_PATH:/} 10 11 gRPCHost: ${SW_CORE_GRPC_HOST:0.0.0.0} 12 13 gRPCPort: ${SW_CORE_GRPC_PORT:11800} 14 15 downsampling: 16 17 - Hour 18 19 - Day 20 21 - Month 22 23 # Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted. 24 25 recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute 26 27 minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute 28 29 hourMetricsDataTTL: ${SW_CORE_HOUR_METRIC_DATA_TTL:36} # Unit is hour 30 31 dayMetricsDataTTL: ${SW_CORE_DAY_METRIC_DATA_TTL:45} # Unit is day 32 33 monthMetricsDataTTL: ${SW_CORE_MONTH_METRIC_DATA_TTL:18} # Unit is month
(2)收集信息存储:支持h2和 ES
storage: 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} # elasticsearch: # # nameSpace: ${SW_NAMESPACE:""} # clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} # indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2} # indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0} # # 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:2000} # Execute the bulk every 2000 requests # bulkSize: ${SW_STORAGE_ES_BULK_SIZE:20} # flush the bulk every 20mb # 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
(3)可采集信息:jvm运行相关信息,zipkin追踪日志等。
1 receiver-register: 2 3 default: 4 5 receiver-trace: 6 7 default: 8 9 bufferPath: ${SW_RECEIVER_BUFFER_PATH:../trace-buffer/} # Path to trace buffer files, suggest to use absolute path 10 11 bufferOffsetMaxFileSize: ${SW_RECEIVER_BUFFER_OFFSET_MAX_FILE_SIZE:100} # Unit is MB 12 13 bufferDataMaxFileSize: ${SW_RECEIVER_BUFFER_DATA_MAX_FILE_SIZE:500} # Unit is MB 14 15 bufferFileCleanWhenRestart: ${SW_RECEIVER_BUFFER_FILE_CLEAN_WHEN_RESTART:false} 16 17 sampleRate: ${SW_TRACE_SAMPLE_RATE:10000} # The sample rate precision is 1/10000. 10000 means 100% sample in default. 18 19 receiver-jvm: 20 21 default: 22 23 #service-mesh: 24 25 # default: 26 27 # bufferPath: ${SW_SERVICE_MESH_BUFFER_PATH:../mesh-buffer/} # Path to trace buffer files, suggest to use absolute path 28 29 # bufferOffsetMaxFileSize: ${SW_SERVICE_MESH_OFFSET_MAX_FILE_SIZE:100} # Unit is MB 30 31 # bufferDataMaxFileSize: ${SW_SERVICE_MESH_BUFFER_DATA_MAX_FILE_SIZE:500} # Unit is MB 32 33 # bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false} 34 35 #istio-telemetry: 36 37 # default: 38 39 #receiver_zipkin: 40 41 # default: 42 43 # host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0} 44 45 # port: ${SW_RECEIVER_ZIPKIN_PORT:9411} 46 47 # contextPath: ${SW_RECEIVER_ZIPKIN_CONTEXT_PATH:/}
访问地址:http://localhost:8080/
首页:
调用关系
服务调用信息
追踪日志信息
Skywalking 采用 Java 探针技术(java agent 博客),对客户端应用程序没有任何代码侵入,使用起来简单方便,当然其具体实现就是需要针对不同的框架及服务提供探针插件。
使用命令:
java -javaagent:G:\github\incubator-skywalking\skywalking-agent\skywalking-agent.jar -Dskywalking.agent.service_name=test -jar app.jar
这样就可以完成对目前应用 app.jar 的监控
Tomcat 监控
Tomcat 7 修改tomcat/bin/catalina.sh,在首行加入如下信息
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/skywalking-agent/skywalking-agent.jar"; export CATALINA_OPTS
Tomcat 8 修改tomcat/bin/catalina.sh,在首行加入如下信息
set "CATALINA_OPTS=... -javaagent:E:\apache-tomcat-8.5.20\skywalking-agent\skywalking-agen