APM全鏈路監(jiān)控:Skywalking出識(1)

一、概念與設(shè)計總覽

SkyWalking: 一個開源的可觀測平臺, 用于從服務(wù)和云原生基礎(chǔ)設(shè)施收集, 分析, 聚合及可視化數(shù)據(jù)。SkyWalking 提供了一種簡便的方式來清晰地觀測分布式系統(tǒng), 甚至橫跨多個云平臺。SkyWalking 更是一個現(xiàn)代化的應(yīng)用程序性能監(jiān)控(Application Performance Monitoring)系統(tǒng), 尤其專為云原生、基于容器的分布式系統(tǒng)設(shè)計

二、基本釋義

1、基本架構(gòu)

Agent

? ? ? ? 負責(zé)從應(yīng)用中,收集鏈路信息,發(fā)送給 SkyWalking OAP 服務(wù)器。目前支持 SkyWalking、Zikpin、Jaeger 等提供的 Tracing 數(shù)據(jù)信息。而我們目前采用的是,SkyWalking Agent 收集 SkyWalking Tracing 數(shù)據(jù),傳遞給服務(wù)器。

SkyWalking OAP

? ? ? ? 負責(zé)接收 Agent 發(fā)送的 Tracing 數(shù)據(jù)信息,然后進行分析(Analysis Core) ,存儲到外部存儲器( Storage ),最終提供查詢( Query )功能。

Storage

? ? ? ? Tracing 數(shù)據(jù)存儲。目前支持 ES、MySQL、Sharding Sphere、TiDB、H2 多種存儲器。而我們目前采用的是 mysql。

SkyWalking UI

? ? ? ? 負責(zé)提供控臺,查看鏈路等等。

2、常見術(shù)語及概念

服務(wù)(Service) :表示對請求提供相同行為的一系列或一組工作負載(同一應(yīng)用名稱)。

服務(wù)實例(Service Instance) :一組工作負載中的每一個工作負載稱為一個實例。就像 Kubernetes 中的 pods 一樣, 服務(wù)實例未必就是操作系統(tǒng)上的一個進程。但當(dāng)你在使用 Agent 的時候, 一個服務(wù)實例實際就是操作系統(tǒng)上的一個真實進程。

這里,我們可以看到 Spring Boot 應(yīng)用的服務(wù)為 {agent_name}-pid:{pid}@{hostname},由 Agent 自動生成。關(guān)于它,我們在「5.1 hostname」小節(jié)中,有進一步的講解,胖友可以瞅瞅。

端點(Endpoint): 對于特定服務(wù)所接收的請求路徑, 如 HTTP 的 URI 路徑和 gRPC 服務(wù)的類名 + 方法簽名。

這里,我們可以看到 Spring Boot 應(yīng)用的一個端點,為 API 接口 /demo/echo。

三、UI視圖與Mysql存儲介紹

OAL數(shù)據(jù)解析語言語法及示例

語法

**// 聲明一個指標(biāo)**

METRICS_NAME = from(SCOPE.(* | [FIELD][,FIELD ...])) // 從某一個SCOPE中獲取數(shù)據(jù)

[.filter(FIELD OP [INT | STRING])] **// 過濾掉部分數(shù)據(jù)**

.FUNCTION([PARAM][, PARAM ...]) **// 使用某個聚合函數(shù)將數(shù)據(jù)聚合**

**// 禁用一個指標(biāo)**

disable(METRICS_NAME);

示例:

// 從ServiceInstanceJVMMemory的used獲取數(shù)據(jù),只需要 heapStatus 為 true的數(shù)據(jù),并取long型的平均值

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

常用術(shù)語

CPM:? ? 吞吐量,表示每分鐘的調(diào)用.

Apdex:? ? 分數(shù),參考Apdex in WIKI

percentile:? ? 響應(yīng)時間百分比,包括 p99, p95, p90, p75, p50.參考percentile in WIKI

SLA:? ? 表示成功率。對于HTTP,表示響應(yīng)為200的請求

常用表釋義

, 記錄了service,instance,endpoint信息

表名 header 2

service_traffic

instance_traffic

endpoint_traffic

1、Dashboard-APM-Global

Service Load(CPM/PPM) 服務(wù)每分鐘請求數(shù),指標(biāo) service_cpm

表名 取數(shù)方式 備注

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

latency: 延遲

Slow Services 慢響應(yīng)服務(wù),單位ms,指標(biāo) service_resp_time

表名 取數(shù)方式 備注

service_resp_time service_resp_time = from(Service.latency).longAvg() 服務(wù)域內(nèi)取出延遲平均值

Apdex 服務(wù)網(wǎng)格健康度

Un-Health Services (Apdex) Apdex性能指標(biāo),1為滿分,指標(biāo)service_apdex

表名 取數(shù)方式 備注

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

Slow Endpoints 慢端口,指標(biāo) endpoint_avg

表名 取數(shù)方式

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

percentile 百分位

Global Response Latency 百分比響應(yīng)延時,不同百分比的延時時間,單位ms。指標(biāo)all_percentile

表名 取數(shù)方式 備注

all_percentile all_percentile = from(All.latency).percentile(10) // Multiple values including p50, p75, p90, p95, p99 延遲數(shù)據(jù)所占百分位

Global Heatmap 服務(wù)響應(yīng)時間熱力分布圖

表名 取數(shù)方式 備注

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

2、Dashboard-APM-Service

duration 持續(xù)時間

Service Apdex 服務(wù)網(wǎng)格健康度(1為滿分),指標(biāo)service_apdex。此處兩個展圖,分別選擇不同的方式一個展示,持續(xù)期間的single value,一個持續(xù)期間all value

表名 取數(shù)方式 備注

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 平均響應(yīng)延時,指標(biāo):service_resp_time,詳Global內(nèi)介紹,此處展示單個服務(wù)持續(xù)時間內(nèi)的響應(yīng)狀態(tài)

表名 取數(shù)方式 備注

service_resp_time service_resp_time = from(Service.latency).longAvg() 服務(wù)域內(nèi)取出延遲平均值 read all values in the duration

Successful Rate 服務(wù)請求成功率,指標(biāo):service_sla

表名 取數(shù)方式 備注

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

Service Load 每分鐘請求數(shù),指標(biāo):service_cpm

表名 取數(shù)方式 備注

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

Service Throughput 每分鐘請求數(shù),指標(biāo):service_throughput_received,service_throughput_sent

表名 取數(shù)方式 備注

---- 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? 每分鐘請求數(shù),指標(biāo):service_instance_cpm

表名 取數(shù)方式 備注

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

Slow Service Instance? 慢服務(wù)實例,指標(biāo):service_instance_resp_time

表名 取數(shù)方式 備注

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

Service Instance Successful Rate? 每個服務(wù)實例請求成功率,指標(biāo):service_instance_sla

表名 取數(shù)方式 備注

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

3、Dashboard-APM-Instance

Service Instance Load? 當(dāng)前實例每分鐘請求數(shù),指標(biāo):service_instance_cpm

表名 取數(shù)方式 備注

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

Throughput 吞吐量

Service Instance Throughput? 當(dāng)前實例吞吐量,指標(biāo):service_instance_throughput_received,service_instance_throughput_sent

表名 取數(shù)方式 備注

---- 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? 當(dāng)前實例請求延遲情況,指標(biāo):service_instance_resp_time

表名 取數(shù)方式 備注

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

JVM CPU (Java Service)? jvm占用CPU的百分比,指標(biāo):instance_jvm_cpu

表名 取數(shù)方式 備注

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

JVM Memory (Java Service)? JVM內(nèi)存占用大小,單位m,指標(biāo):instance_jvm_memory_heap, instance_jvm_memory_heap_max,instance_jvm_memory_noheap, instance_jvm_memory_noheap_max

表名 取數(shù)方式 備注

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 統(tǒng)計,指標(biāo):instance_jvm_class_loaded_class_count, instance_jvm_class_total_unloaded_class_count, instance_jvm_class_total_loaded_class_count

表名 取數(shù)方式 備注

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相關(guān)暫不做解釋,指標(biāo):instance_clr_cpu

表名 取數(shù)方式 備注

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

4、Dashboard-APM-Endpoints

Endpoint Load in Current Service? 每個端點的每分鐘請求數(shù),指標(biāo):endpoint_cpm

表名 取數(shù)方式 備注

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

Slow Endpoints in Current Service? 端點的慢請求時間排行,單位ms,指標(biāo):endpoint_avg

表名 取數(shù)方式 備注

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

Successful Rate in Current Service? 每個端點的請求成功率,指標(biāo):endpoint_sla

表名 取數(shù)方式 備注

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

Endpoint Load? 每個端點的每分鐘請求數(shù),指標(biāo):endpoint_cpm

表名 取數(shù)方式 備注

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

Endpoint Avg Response Time? 當(dāng)前端點每個時間段的請求行響應(yīng)時間,單位ms,指標(biāo):endpoint_avg

表名 取數(shù)方式 備注

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

Endpoint Response Time Percentile? 當(dāng)前端點每個時間段的響應(yīng)時間占比,單位ms,指標(biāo):endpoint_percentile

表名 取數(shù)方式 備注

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? 當(dāng)前端點每個時間段的請求成功率,指標(biāo):endpoint_sla

表名 取數(shù)方式 備注

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

優(yōu)化配置

1、修改采樣頻率

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

默認配置10000,采樣率精確到1/10000,即10000 * 1/10000 = 1 = 100%。

假設(shè)我們設(shè)計采樣50%,那么設(shè)置為5000,具體如下:

receiver-trace:

? selector: ${SW_RECEIVER_TRACE:default}

? default:

? ? sampleRate: ${SW_TRACE_SAMPLE_RATE:5000}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容