Ease Monitor 產(chǎn)品文檔

http://megaease.com/docs/monitor/

1. 產(chǎn)品定位

Ease Monitor 有如下的產(chǎn)品定位:

  • 關(guān)注于整體應(yīng)用的SLA。 主要從為用戶服務(wù)的 API 來(lái)監(jiān)控整個(gè)系統(tǒng)。

  • 關(guān)聯(lián)指標(biāo)聚合。 把有關(guān)聯(lián)的系統(tǒng)及其指示聚合展示。主要是三層系統(tǒng)數(shù)據(jù):基礎(chǔ)層、平臺(tái)中間件層和應(yīng)用層。

  • 快速故障定位。 對(duì)于現(xiàn)有的系統(tǒng)來(lái)說(shuō),故障總是會(huì)發(fā)生的,而且還是會(huì)頻繁發(fā)生。故障發(fā)生不可怕,可怕的是故障的恢復(fù)時(shí)間過(guò)長(zhǎng)。所以,快速的定位故障就相當(dāng)關(guān)鍵。 換句話說(shuō),Ease Monitor 主要是為以下兩個(gè)場(chǎng)景所設(shè)計(jì)的:

  1. “體檢”

    • 容量管理。 提供一個(gè)全局的系統(tǒng)運(yùn)行時(shí)數(shù)據(jù)的展示,可以讓工程師團(tuán)隊(duì)知道是否需要增加機(jī)器或是其它資源。

    • 性能管理??梢酝ㄟ^(guò)查看大盤(pán),找到系統(tǒng)瓶頸,并有針對(duì)性的優(yōu)化系統(tǒng)和相應(yīng)代碼。

  2. “急診”

    • 定位問(wèn)題??梢钥焖俚谋┞恫⒄业絾?wèn)題的發(fā)生點(diǎn),幫助技術(shù)人員診斷問(wèn)題。

    • 性能分析。當(dāng)出來(lái)不預(yù)期的流量提升,可以快速的找到系統(tǒng)的瓶頸,并可以幫助開(kāi)發(fā)人員深入代碼。

下圖是一個(gè)很常見(jiàn)的情況:

Diagnosis Case

2. 設(shè)計(jì)原則

Ease Monitor 其實(shí)是一種 APM - Application Performance Management,但是又不同于傳統(tǒng)意議上的 APM 軟件。

主要有下面兩個(gè)方面影響了 Ease Monitor 的設(shè)計(jì):

  • 不同的工程視角。我們知道,在很多公司有不同的工程師角色,如:開(kāi)發(fā)、應(yīng)用運(yùn)維、系統(tǒng)運(yùn)維等等,他們會(huì)站在不同的地方來(lái)看一個(gè)系統(tǒng),例如:

    • 經(jīng)理們主要關(guān)心的是整個(gè)系統(tǒng)的運(yùn)行健康情況,不太關(guān)注細(xì)節(jié)。
    • 軟件開(kāi)發(fā)工程師主要關(guān)注應(yīng)用的運(yùn)行狀態(tài)。
    • 運(yùn)維人員主要關(guān)注底層和各種中間件的運(yùn)行狀態(tài)。
  • 不重新發(fā)明輪子。重新開(kāi)發(fā)一個(gè)監(jiān)控就像是重新發(fā)明一個(gè)輪子,因?yàn)檫@個(gè)世界上已經(jīng)有很多的監(jiān)控系統(tǒng)了。所以,我們不想重新發(fā)明輪子。我們希望我們的 Ease Monitor 是一個(gè)可以足夠兼容現(xiàn)有的主流的監(jiān)控軟件,并且可以像樂(lè)高玩具一樣,可以做到其中的組件隨意替換隨意剪裁的效果。

所以,Ease Monitor 有如下的設(shè)計(jì)源則:

  • 使用主流的技術(shù)。 我們希望我們使用的技術(shù)是絕大多數(shù)的工程師團(tuán)隊(duì)熟悉并可以運(yùn)維的。

  • 組件都可以被替換和被裁剪。 因?yàn)椴煌膱?chǎng)景有不同的需求和業(yè)務(wù)形態(tài),所以,設(shè)計(jì)必需做到有足夠的靈活度可以容易地替換或裁剪相當(dāng)?shù)慕M件。

  • 跟蹤用戶請(qǐng)求。 可以在一個(gè)分布式的系統(tǒng),從端到端跟蹤整個(gè)用戶的調(diào)用。

  • 引導(dǎo)工程能力。 好的一個(gè)監(jiān)控致少可以讓工程師做兩件事:
    1)快速地定位故障,
    2)容易的做出工程上的決定。

  • 驅(qū)動(dòng)自動(dòng)化。 一個(gè)好的監(jiān)控系統(tǒng)可以和現(xiàn)有的集群控制系統(tǒng)關(guān)聯(lián)起來(lái),做自動(dòng)化運(yùn)維。如:自動(dòng)化擴(kuò)展,或是自動(dòng)化的資源或流量調(diào)度。

  • 全棧監(jiān)控。我們必需對(duì)三層軟件進(jìn)行監(jiān)控:

    • 應(yīng)用服務(wù)層。 在這一層上,主要是對(duì)應(yīng)用服務(wù)的關(guān)鍵指針進(jìn)行監(jiān)控,如:HTTP request, Status code, Throughput, Latency ...等等。
    • 平臺(tái)中間件層。 在這一層上,主要是參考相關(guān)的中間件進(jìn)行監(jiān)控,如:Nginx, Redis, Tomcat, Kafka, MySQL... 等等。
    • 基礎(chǔ)層。 在這一層上,主要是對(duì)相關(guān)主機(jī)的操作系統(tǒng)進(jìn)行監(jiān)控,如:CPU, Memory, Disk, Network ... 等等。
  • 自定義的儀表盤(pán)。 不同的用戶有不同的視角,所以,用戶可以定義自己感興趣的儀表盤(pán)。

3. 系統(tǒng)架構(gòu)設(shè)計(jì)

Ease Monitor Architecture

上圖是整個(gè) Ease Monitor 的架構(gòu)圖所用到的技術(shù)。

  • 數(shù)據(jù)采集端
    • 基礎(chǔ)層和中間件指標(biāo)采集 - Collectd
    • 日志采集 - Filebeat
    • Java Agent - Ease Agent (我們自研了這個(gè)組件。詳見(jiàn) “技術(shù)細(xì)節(jié)” 一節(jié))
    • iOS/Android SDK - 這個(gè)組件由“餓了么”技術(shù)團(tuán)隊(duì)開(kāi)發(fā)。詳見(jiàn) “技術(shù)細(xì)節(jié)” 一節(jié)。
  • 數(shù)據(jù)處理管線
    • 數(shù)據(jù)總線 - Apache Kafka
    • 數(shù)據(jù) ETL - Logstash
    • 數(shù)據(jù)存儲(chǔ) - ElasticSearch
    • 報(bào)警數(shù)據(jù) - InfluxDB
    • 報(bào)警觸發(fā)和報(bào)警處理 - 我們自研了這個(gè)組件。詳見(jiàn) “技術(shù)細(xì)節(jié)” 一節(jié)
    • Web前端控制臺(tái) - 我們自研了這個(gè)組件。詳見(jiàn) “技術(shù)細(xì)節(jié)” 一節(jié)

對(duì)于這個(gè)技術(shù)架構(gòu),其中的技術(shù)都是主流的成熟的,其被設(shè)計(jì)于可以監(jiān)控一個(gè)規(guī)模很大的集群,而且其中的組件是可以被靈活的裁剪和取代。

4. 系統(tǒng)要求和限制

目前,Ease Monitor 只支持如下的系統(tǒng)環(huán)境。

  • Java 語(yǔ)言系的應(yīng)用。Java的版本得 >= 1.6
  • Linux 操作系統(tǒng)。

5. 功能展示

5.1 總體儀表板

總體儀表板主要展示了系統(tǒng)整體的健康和容量情況。

Overview Dashboard

5.2 系統(tǒng)請(qǐng)求排名列表

系統(tǒng)請(qǐng)求排名列表列出了系統(tǒng)比較耗時(shí)的請(qǐng)求以及相關(guān)的請(qǐng)求熱點(diǎn)。

Nginx 請(qǐng)求排名列表

Nginx 請(qǐng)求排名列表

JDBC 數(shù)據(jù)庫(kù)操作排名列表

JDBC 數(shù)據(jù)庫(kù)操作排名列表

5.3 函數(shù)調(diào)用棧分析

下圖是某個(gè)請(qǐng)求的函數(shù)調(diào)用棧分析

Call Stack

5.4 調(diào)用鏈跟蹤

下圖展示了一個(gè)請(qǐng)求在整個(gè)系統(tǒng)中的服務(wù)調(diào)用鏈以及相應(yīng)的時(shí)間分布。

External Service

5.5 可自由定制的儀表盤(pán)

基礎(chǔ)操作系統(tǒng)的儀表盤(pán)

Dashboard

5.6 事件報(bào)警

下圖是一個(gè)事件報(bào)警的報(bào)告圖

Events

6. 技術(shù)細(xì)節(jié)

6.1 Ease Agent

Ease Agent 是一種 Java Agent ,它在運(yùn)行時(shí)期間使用 java.lang.instrument API 對(duì)特定方法進(jìn)行 字節(jié)碼增強(qiáng) ,以實(shí)現(xiàn)方法調(diào)用的上下文信息的采集,如:對(duì)于用戶請(qǐng)求的時(shí)間測(cè)量,函數(shù)調(diào)用棧的信息,分布式系統(tǒng)的調(diào)用鏈跟蹤,等等。

6.1.1 Design Principles

考慮到 Ease Agent 與宿主進(jìn)程運(yùn)行在同一個(gè) JVM 中,所以其 可靠性弱干擾性 尤為重要, 為此它被設(shè)計(jì)為:

  1. 獨(dú)立的 ClassLoader。 采用獨(dú)立的 ClassLoader 裝載自身字節(jié)碼,與宿主字節(jié)碼相隔離, 從而避免字節(jié)碼沖突。
  2. 精巧的裝載技術(shù)。 精巧的自定義裝載機(jī)制允許自身共享宿主已有字節(jié)碼, 大幅減少冗余字節(jié)碼的依賴, 讓部署和運(yùn)行更為高效。
  3. 高效的采樣技術(shù)。 多種調(diào)用采樣機(jī)制可供選擇, 滿足不同場(chǎng)景下對(duì)于性能的苛刻要求。
  4. 簡(jiǎn)易的擴(kuò)展性。 內(nèi)建一套簡(jiǎn)潔的 DSL ,令擴(kuò)展功能可在十來(lái)行代碼中得以實(shí)現(xiàn)。

6.1.2 兼容性與要求

  1. 支持 Oracle JDKOpenJDK 6 到 8。
  2. 支持所有兼容 Java Servlet 3.0 的 Servlet 容器, 如 Tomcat,JettyJBoss 等。
  3. 支持所有兼容 JDBC 的數(shù)據(jù)庫(kù)驅(qū)動(dòng),部分高級(jí)特性支持 MySQL (mysql-connector-java v5.1.33
  4. 支持 Apache HTTP Client v4.5.x
  5. 支持 Jedis v2.9.x
  6. 支持 Spring RestTemplate v4.x
  7. 支持 Zipkin v1.19.2+

6.1.3 采集數(shù)據(jù)種類(lèi)

  1. 服務(wù)器收到 HTTP 請(qǐng)求的 Metric,以及調(diào)用關(guān)聯(lián)信息(如調(diào)用棧等)
  2. JDBC Connection 獲取和 Statement 執(zhí)行的 Metric, 以及調(diào)用關(guān)聯(lián)信息(如 URL,SQL等)
  3. 兼容 Zipkin 協(xié)議的分布式調(diào)用鏈數(shù)據(jù),包括:
    • HTTP 接收 與 發(fā)送
    • SQL 執(zhí)行
    • Redis 訪問(wèn)

6.1.4 安裝與使用

下載 easeagent-dep.jar 后, 添加如下 Java 運(yùn)行時(shí)參數(shù):

-javaagent=easeagent-dep.jar

6.2 iOS/Android SDK

coming soon...

6.3 事件報(bào)警

當(dāng)前,Ease Monitor 的事件報(bào)警支持如下的用戶案例。

  • 指標(biāo) - 持續(xù)時(shí)間 - 閾值。 當(dāng)一個(gè)指標(biāo)在一個(gè)時(shí)間段內(nèi)持續(xù)超過(guò)所配置的閾值,引發(fā)報(bào)警。如:在兩分鐘內(nèi) cpu 利用率持續(xù)超過(guò) 80% 。

  • 指標(biāo) - 持續(xù)時(shí)間 - 百分比分布 - 閾值。 當(dāng)一個(gè)指標(biāo)在一個(gè)時(shí)間段間的某個(gè)百分比分布超過(guò)所配置的閾值,引發(fā)報(bào)警。如:99%的請(qǐng)求響應(yīng)時(shí)間在兩分鐘內(nèi)超過(guò) 300ms (即:P99)

  • 指標(biāo) - 持續(xù)時(shí)間 - 函數(shù) - 閾值。 支持一些簡(jiǎn)單的函數(shù)計(jì)算 Sum/Average/Min/Max/Count。如:在兩分鐘內(nèi) JVM 的 GC 次數(shù)超過(guò)所配置的閾值(使用Sum函數(shù))。

  • 日志 - 持續(xù)時(shí)間 - 關(guān)鍵詞 - 匹配次數(shù)。監(jiān)控日志中某個(gè)關(guān)鍵詞在一個(gè)時(shí)間段內(nèi)出現(xiàn)的次數(shù)超過(guò)某個(gè)數(shù)量,引發(fā)報(bào)警。關(guān)鍵詞支持正規(guī)表達(dá)式匹配。

6.4 數(shù)據(jù)存儲(chǔ)格式

下面是 Ease Monitor 在 ElasticSearch 中的數(shù)據(jù)存儲(chǔ)格式。

6.4.1 索引格式

Index mapping template Index pattern Description
ease-monitor-metrics-* ease-monitor-metrics-YYYY.MM.DD Saves time series based metrics of monitored object from different categories. The metrics from different monitored object will be saved into a dedicated document type.
ease-monitor-aggregate-metrics-* ease-monitor-aggregate-metrics-YYYY.MM.DD Saves calculated performance statistics from different dimensions monitoring requirement needed. The statistics from different dimensions will be saved into a dedicated document type. Due to the statistic calculation are executed on these input metrics directly as streaming and the results will be saved into this index in advance, so the statistics can be loaded and used without any further aggregation(e.g. grouping and computing). This will definitely help the performance of ad-hoc query on the fine-grained metrics ES stored, especially on a large metrics data volume. This index was designed only to save these statistics ones can be calculated by a simple (fast) and fixed (can be implemented on product design stage instead of runtime stage) functions.
ease-monitor-logs-* ease-monitor-logs-YYYY.MM.DD Saves the logs outputted from OS, middleware and application. The different logs will be saved into a dedicated document type.

6.4.2 文檔類(lèi)型格式

我們有如下的文檔類(lèi)型的存儲(chǔ)格式:

  • Index mapping template

    • ease-monitor-metrics-* - 用于存儲(chǔ)時(shí)序類(lèi)型的指標(biāo)數(shù)據(jù)。
    • ease-monitor-aggregate-metrics-* - 用于存儲(chǔ) Java Agent 所采集的數(shù)據(jù)。
    • ease-monitor-logs-* - 用于存儲(chǔ)日志數(shù)據(jù)。
  • Category

    • application - 表明是應(yīng)用層的數(shù)據(jù)種類(lèi)。
    • platform - 表明是平臺(tái)層中間件的數(shù)據(jù)種類(lèi)。如:nginx, redis, tomcat, mysql, kafka ... 等等。
    • infrastructure - 表明是基礎(chǔ)層的數(shù)據(jù)種類(lèi)。如: CPU, MEM, DISK, NET 指標(biāo)。
  • Document Type

    • 組件名稱
    • 組件的指標(biāo)和統(tǒng)計(jì)名。

相關(guān)示例:

Index mapping template Category Document type Description
ease-monitor-metrics-* application http_request Saves application HTTP request records, which contains URL address and parameters, execution duration, response code and other useful fields.
platform jvm_memory Saves JVM performance counters and statistics for heap, non-heap and each spaces.
jvm_gc Saves JVM performance counters and statistics for garbage collector.
tomcat_global Saves the performance counters and statistics of global request processor and thread pool.
tomcat_cache Saves the performance counters and statistics of each context cache.
tomcat_servlet Saves the performance counters and statistics of each servlet.
nginx Saves nginx performance counters and statistics.
mysql Saves mysql performance counters and statistics.
redis_server Saves redis server performance counters and statistics.
redis_keyspace Saves redis key space performance counters and statistics.
infrastructure cpu Saves the percentage utilization of special logic core.
memory Saves the percentage utilization and capacity in bytes.
interface Saves the performance counters and statistics for each interface separately (without 'lo' loop device), e.g. tx and rx bytes.
disk Saves the performance counters and statistics for each block device separately, e.g. iops, mbps. (busy percentage indicator will be added in future).
df Saves the utilization counters for each block device
ease-monitor-aggregate-metrics-* application http_request Saves the calculated values of separated and total executions per second in every 1, 5, 15 minutes. The request count will be saved as well.
jdbc_statement Saves the calculated values of separated and total executions per second in every 1, 5, 15 minutes. And also saves minimal, mean, maximal and 25%, 50%, 75%, 95%, 98%, 99%, 99.9% user's execution duration. The execution count will be saved as well.
jdbc_connection Saves the calculated values of database connection establishment per second in every 1, 5, 15 minutes range. And also saves minimal, mean , maximal and 25%, 50%, 75%, 95%, 98%, 99%, 99.9% user's connection establishment duration. The establishment count will be saved as well.
ease-monitor-logs-* application <component-name> Saves log records collected from application's component.
platform tomcat_exception Saves the exception messages of the stack.
nginx_access Saves HTTP access records from nginx access log.
nginx_error Saves error records from nginx error log.
mysql_slow_sql Saves slow SQL records from MySQL log.
infrastructure os_syslog Saves log records from OS 'syslog' file.
os_dmesg Saves log records from OS 'dmesg' file.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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