APM全链路监控:Skywalking出识(1)

一、概念与设计总览

SkyWalking: 一个开源的可观测平台, 用于从服务和云原生基础设施收集, 分析, 聚合及可视化数据。SkyWalking 提供了一种简便的方式来清晰地观测分布式系统, 甚至横跨多个云平台。SkyWalking 更是一个现代化的应用程序性能监控(Application Performance Monitoring)系统, 尤其专为云原生、基于容器的分布式系统设计

二、基本释义

1、基本架构

Agent

        负责从应用中,收集链路信息,发送给 SkyWalking OAP 服务器。目前支持 SkyWalking、Zikpin、Jaeger 等提供的 Tracing 数据信息。而我们目前采用的是,SkyWalking Agent 收集 SkyWalking Tracing 数据,传递给服务器。

SkyWalking OAP

        负责接收 Agent 发送的 Tracing 数据信息,然后进行分析(Analysis Core) ,存储到外部存储器( Storage ),最终提供查询( Query )功能。

Storage

        Tracing 数据存储。目前支持 ES、MySQL、Sharding Sphere、TiDB、H2 多种存储器。而我们目前采用的是 mysql。

SkyWalking UI

        负责提供控台,查看链路等等。

2、常见术语及概念

服务(Service) :表示对请求提供相同行为的一系列或一组工作负载(同一应用名称)。

服务实例(Service Instance) :一组工作负载中的每一个工作负载称为一个实例。就像 Kubernetes 中的 pods 一样, 服务实例未必就是操作系统上的一个进程。但当你在使用 Agent 的时候, 一个服务实例实际就是操作系统上的一个真实进程。

这里,我们可以看到 Spring Boot 应用的服务为 {agent_name}-pid:{pid}@{hostname},由 Agent 自动生成。关于它,我们在「5.1 hostname」小节中,有进一步的讲解,胖友可以瞅瞅。

端点(Endpoint): 对于特定服务所接收的请求路径, 如 HTTP 的 URI 路径和 gRPC 服务的类名 + 方法签名。

这里,我们可以看到 Spring Boot 应用的一个端点,为 API 接口 /demo/echo。

三、UI视图与Mysql存储介绍

OAL数据解析语言语法及示例

语法

**// 声明一个指标**

METRICS_NAME = from(SCOPE.(* | [FIELD][,FIELD ...])) // 从某一个SCOPE中获取数据

[.filter(FIELD OP [INT | STRING])] **// 过滤掉部分数据**

.FUNCTION([PARAM][, PARAM ...]) **// 使用某个聚合函数将数据聚合**

**// 禁用一个指标**

disable(METRICS_NAME);

示例:

// 从ServiceInstanceJVMMemory的used获取数据,只需要 heapStatus 为 true的数据,并取long型的平均值

instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg();

常用术语

CPM:    吞吐量,表示每分钟的调用.

Apdex:    分数,参考Apdex in WIKI

percentile:    响应时间百分比,包括 p99, p95, p90, p75, p50.参考percentile in WIKI

SLA:    表示成功率。对于HTTP,表示响应为200的请求

常用表释义

, 记录了service,instance,endpoint信息

表名 header 2

service_traffic

instance_traffic

endpoint_traffic

1、Dashboard-APM-Global

Service Load(CPM/PPM) 服务每分钟请求数,指标 service_cpm

表名 取数方式 备注

service_cpm service_cpm = from(Service.*).cpm() 展示方式:get sorted top N values

latency: 延迟

Slow Services 慢响应服务,单位ms,指标 service_resp_time

表名 取数方式 备注

service_resp_time service_resp_time = from(Service.latency).longAvg() 服务域内取出延迟平均值

Apdex 服务网格健康度

Un-Health Services (Apdex) Apdex性能指标,1为满分,指标service_apdex

表名 取数方式 备注

service_apdex service_apdex = from(Service.latency).apdex(name, status) 展示方式: get sorted top N values(edit界面可以看的到)

Slow Endpoints 慢端口,指标 endpoint_avg

表名 取数方式

endpoint_avg endpoint_avg = from(Endpoint.latency).longAvg()

percentile 百分位

Global Response Latency 百分比响应延时,不同百分比的延时时间,单位ms。指标all_percentile

表名 取数方式 备注

all_percentile all_percentile = from(All.latency).percentile(10) // Multiple values including p50, p75, p90, p95, p99 延迟数据所占百分位

Global Heatmap 服务响应时间热力分布图

表名 取数方式 备注

all_heatmap all_heatmap = from(All.latency).histogram(100, 20);

2、Dashboard-APM-Service

duration 持续时间

Service Apdex 服务网格健康度(1为满分),指标service_apdex。此处两个展图,分别选择不同的方式一个展示,持续期间的single value,一个持续期间all value

表名 取数方式 备注

service_apdex service_apdex = from(Service.latency).apdex(name, status) Global界面 read the single value in the duration(read all values in the duration)(edit界面可以看的到)

Service Avg Response Time 平均响应延时,指标:service_resp_time,详Global内介绍,此处展示单个服务持续时间内的响应状态

表名 取数方式 备注

service_resp_time service_resp_time = from(Service.latency).longAvg() 服务域内取出延迟平均值 read all values in the duration

Successful Rate 服务请求成功率,指标:service_sla

表名 取数方式 备注

service_sla service_sla = from(Service.*).percent(status == true) 展示方式:read the single value in the duration(read all values in the duration)

Service Load 每分钟请求数,指标:service_cpm

表名 取数方式 备注

service_cpm service_cpm = from(Service.*).cpm() 展示方式:read the single value in the duration(read all values in the duration)

Service Throughput 每分钟请求数,指标:service_throughput_received,service_throughput_sent

表名 取数方式 备注

---- service_throughput_received = from(Service.tcpInfo.receivedBytes).filter(type == RequestType.TCP).longAvg()

service_throughput_sent = from(Service.tcpInfo.sentBytes).filter(type == RequestType.TCP).longAvg() 展示方式:read all values in the duration

Service Instances Load  每分钟请求数,指标:service_instance_cpm

表名 取数方式 备注

service_instance_cpm service_instance_cpm = from(ServiceInstance.*).cpm() 展示方式:get sorted top N values

Slow Service Instance  慢服务实例,指标:service_instance_resp_time

表名 取数方式 备注

service_instance_resp_time service_instance_resp_time= from(ServiceInstance.latency).longAvg() 展示方式:get sorted top N values

Service Instance Successful Rate  每个服务实例请求成功率,指标:service_instance_sla

表名 取数方式 备注

service_instance_sla service_instance_sla = from(ServiceInstance.*).percent(status == true) 展示方式:get sorted top N values

3、Dashboard-APM-Instance

Service Instance Load  当前实例每分钟请求数,指标:service_instance_cpm

表名 取数方式 备注

service_instance_cpm service_instance_cpm = from(ServiceInstance.*).cpm() 展示方式:read all values in the duration

Throughput 吞吐量

Service Instance Throughput  当前实例吞吐量,指标:service_instance_throughput_received,service_instance_throughput_sent

表名 取数方式 备注

---- service_instance_throughput_received = from(ServiceInstance.tcpInfo.receivedBytes).filter(type == RequestType.TCP).longAvg(),

service_instance_throughput_sent = from(ServiceInstance.tcpInfo.sentBytes).filter(type == RequestType.TCP).longAvg() 展示方式:read all values in the duration

Service Instance Latency  当前实例请求延迟情况,指标:service_instance_resp_time

表名 取数方式 备注

service_instance_resp_time service_instance_resp_time= from(ServiceInstance.latency).longAvg() 展示方式:read all values in the duration

JVM CPU (Java Service)  jvm占用CPU的百分比,指标:instance_jvm_cpu

表名 取数方式 备注

instance_jvm_cpu instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg() 展示方式:read all values in the duration

JVM Memory (Java Service)  JVM内存占用大小,单位m,指标:instance_jvm_memory_heap, instance_jvm_memory_heap_max,instance_jvm_memory_noheap, instance_jvm_memory_noheap_max

表名 取数方式 备注

instance_jvm_memory_heap,

instance_jvm_memory_heap_max,

instance_jvm_memory_noheap,

instance_jvm_memory_noheap_max instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg();

instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg();

instance_jvm_memory_heap_max = from(ServiceInstanceJVMMemory.max).filter(heapStatus == true).longAvg();

instance_jvm_memory_noheap_max = from(ServiceInstanceJVMMemory.max).filter(heapStatus == false).longAvg(); 展示方式:read all values in the duration

JVM Class Count (Java Service)  jvm class 统计,指标:instance_jvm_class_loaded_class_count, instance_jvm_class_total_unloaded_class_count, instance_jvm_class_total_loaded_class_count

表名 取数方式 备注

instance_jvm_class_loaded_class_count,

instance_jvm_class_total_unloaded_class_count,

instance_jvm_class_total_loaded_class_count instance_jvm_class_loaded_class_count = from(ServiceInstanceJVMClass.loadedClassCount).longAvg();

instance_jvm_class_total_unloaded_class_count = from(ServiceInstanceJVMClass.totalUnloadedClassCount).longAvg();

instance_jvm_class_total_loaded_class_count = from(ServiceInstanceJVMClass.totalLoadedClassCount).longAvg(); 展示方式:read all values in the duration

CLR CPU (.NET Service)  CLR .NET相关暂不做解释,指标:instance_clr_cpu

表名 取数方式 备注

instance_clr_cpu instance_clr_cpu = from(ServiceInstanceCLRCPU.usePercent).doubleAvg(); 展示方式:get sorted top N values

4、Dashboard-APM-Endpoints

Endpoint Load in Current Service  每个端点的每分钟请求数,指标:endpoint_cpm

表名 取数方式 备注

endpoint_cpm endpoint_cpm = from(Endpoint.*).cpm(); 展示方式:get sorted top N values

Slow Endpoints in Current Service  端点的慢请求时间排行,单位ms,指标:endpoint_avg

表名 取数方式 备注

endpoint_avg endpoint_avg = from(Endpoint.latency).longAvg(); 展示方式:get sorted top N values

Successful Rate in Current Service  每个端点的请求成功率,指标:endpoint_sla

表名 取数方式 备注

endpoint_sla endpoint_sla = from(Endpoint.*).percent(status == true); 展示方式:get sorted top N values

Endpoint Load  每个端点的每分钟请求数,指标:endpoint_cpm

表名 取数方式 备注

endpoint_cpm endpoint_cpm = from(Endpoint.*).cpm(); 展示方式:read all values in the duration

Endpoint Avg Response Time  当前端点每个时间段的请求行响应时间,单位ms,指标:endpoint_avg

表名 取数方式 备注

endpoint_avg endpoint_avg = from(Endpoint.latency).longAvg(); 展示方式:read all values in the duration

Endpoint Response Time Percentile  当前端点每个时间段的响应时间占比,单位ms,指标:endpoint_percentile

表名 取数方式 备注

endpoint_percentile endpoint_percentile = from(Endpoint.latency).percentile(10); // Multiple values including p50, p75, p90, p95, p99 展示方式:read all values in the duration

Endpoint Successful Rate  当前端点每个时间段的请求成功率,指标:endpoint_sla

表名 取数方式 备注

endpoint_sla endpoint_sla = from(Endpoint.*).percent(status == true); 展示方式:read all values in the duration

优化配置

1、修改采样频率

具体配置在config/application.yml文件中receiver-trace模块。

默认配置10000,采样率精确到1/10000,即10000 * 1/10000 = 1 = 100%。

假设我们设计采样50%,那么设置为5000,具体如下:

receiver-trace:

  selector: ${SW_RECEIVER_TRACE:default}

  default:

    sampleRate: ${SW_TRACE_SAMPLE_RATE:5000}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容