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}

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,457评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,837评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,696评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,183评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,057评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,105评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,520评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,211评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,482评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,574评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,353评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,897评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,489评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,683评论 2 335

推荐阅读更多精彩内容