http://megaease.com/docs/monitor/
1. 產(chǎn)品定位
Ease Monitor
有如下的產(chǎn)品定位:
關(guān)注于整體應(yīng)用的SLA罢防。 主要從為用戶服務(wù)的 API 來監(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)用層。
快速故障定位。 對于現(xiàn)有的系統(tǒng)來說朦蕴,故障總是會(huì)發(fā)生的,而且還是會(huì)頻繁發(fā)生弟头。故障發(fā)生不可怕吩抓,可怕的是故障的恢復(fù)時(shí)間過長。所以赴恨,快速的定位故障就相當(dāng)關(guān)鍵疹娶。 換句話說,
Ease Monitor
主要是為以下兩個(gè)場景所設(shè)計(jì)的:
-
“體檢”
容量管理伦连。 提供一個(gè)全局的系統(tǒng)運(yùn)行時(shí)數(shù)據(jù)的展示雨饺,可以讓工程師團(tuán)隊(duì)知道是否需要增加機(jī)器或是其它資源。
性能管理惑淳《罡郏可以通過查看大盤,找到系統(tǒng)瓶頸歧焦,并有針對性的優(yōu)化系統(tǒng)和相應(yīng)代碼移斩。
-
“急診”
定位問題∫幸ǎ可以快速的暴露并找到問題的發(fā)生點(diǎn)叹哭,幫助技術(shù)人員診斷問題。
性能分析痕貌。當(dāng)出來不預(yù)期的流量提升风罩,可以快速的找到系統(tǒng)的瓶頸,并可以幫助開發(fā)人員深入代碼舵稠。
下圖是一個(gè)很常見的情況:
2. 設(shè)計(jì)原則
Ease Monitor
其實(shí)是一種 APM - Application Performance Management超升,但是又不同于傳統(tǒng)意議上的 APM 軟件。
主要有下面兩個(gè)方面影響了 Ease Monitor
的設(shè)計(jì):
-
不同的工程視角哺徊。我們知道室琢,在很多公司有不同的工程師角色,如:開發(fā)落追、應(yīng)用運(yùn)維盈滴、系統(tǒng)運(yùn)維等等,他們會(huì)站在不同的地方來看一個(gè)系統(tǒng),例如:
- 經(jīng)理們主要關(guān)心的是整個(gè)系統(tǒng)的運(yùn)行健康情況巢钓,不太關(guān)注細(xì)節(jié)病苗。
- 軟件開發(fā)工程師主要關(guān)注應(yīng)用的運(yùn)行狀態(tài)。
- 運(yùn)維人員主要關(guān)注底層和各種中間件的運(yùn)行狀態(tài)症汹。
不重新發(fā)明輪子硫朦。重新開發(fā)一個(gè)監(jiān)控就像是重新發(fā)明一個(gè)輪子,因?yàn)檫@個(gè)世界上已經(jīng)有很多的監(jiān)控系統(tǒng)了背镇。所以咬展,我們不想重新發(fā)明輪子。我們希望我們的
Ease Monitor
是一個(gè)可以足夠兼容現(xiàn)有的主流的監(jiān)控軟件瞒斩,并且可以像樂高玩具一樣破婆,可以做到其中的組件隨意替換隨意剪裁的效果。
所以济瓢,Ease Monitor
有如下的設(shè)計(jì)源則:
使用主流的技術(shù)荠割。 我們希望我們使用的技術(shù)是絕大多數(shù)的工程師團(tuán)隊(duì)熟悉并可以運(yùn)維的妹卿。
組件都可以被替換和被裁剪旺矾。 因?yàn)椴煌膱鼍坝胁煌男枨蠛蜆I(yè)務(wù)形態(tài),所以夺克,設(shè)計(jì)必需做到有足夠的靈活度可以容易地替換或裁剪相當(dāng)?shù)慕M件箕宙。
跟蹤用戶請求。 可以在一個(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)起來其馏,做自動(dòng)化運(yùn)維凤跑。如:自動(dòng)化擴(kuò)展,或是自動(dòng)化的資源或流量調(diào)度叛复。
-
全棧監(jiān)控仔引。我們必需對三層軟件進(jìn)行監(jiān)控:
-
應(yīng)用服務(wù)層。 在這一層上褐奥,主要是對應(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ǔ)層夫否。 在這一層上找筝,主要是對相關(guān)主機(jī)的操作系統(tǒng)進(jìn)行監(jiān)控,如:
CPU
,Memory
,Disk
,Network
... 等等慷吊。
-
應(yīng)用服務(wù)層。 在這一層上褐奥,主要是對應(yīng)用服務(wù)的關(guān)鍵指針進(jìn)行監(jiān)控咖耘,如:
自定義的儀表盤袖裕。 不同的用戶有不同的視角,所以溉瓶,用戶可以定義自己感興趣的儀表盤急鳄。
3. 系統(tǒng)架構(gòu)設(shè)計(jì)
上圖是整個(gè) Ease Monitor
的架構(gòu)圖所用到的技術(shù)。
- 數(shù)據(jù)采集端
-
數(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è)組件触创。詳見 “技術(shù)細(xì)節(jié)” 一節(jié)
- Web前端控制臺(tái) - 我們自研了這個(gè)組件坎藐。詳見 “技術(shù)細(xì)節(jié)” 一節(jié)
對于這個(gè)技術(shù)架構(gòu),其中的技術(shù)都是主流的成熟的哼绑,其被設(shè)計(jì)于可以監(jiān)控一個(gè)規(guī)模很大的集群岩馍,而且其中的組件是可以被靈活的裁剪和取代。
4. 系統(tǒng)要求和限制
目前抖韩,Ease Monitor
只支持如下的系統(tǒng)環(huán)境蛀恩。
- Java 語言系的應(yīng)用。Java的版本得 >= 1.6
- Linux 操作系統(tǒng)茂浮。
5. 功能展示
5.1 總體儀表板
總體儀表板主要展示了系統(tǒng)整體的健康和容量情況双谆。
5.2 系統(tǒng)請求排名列表
系統(tǒng)請求排名列表列出了系統(tǒng)比較耗時(shí)的請求以及相關(guān)的請求熱點(diǎn)。
Nginx 請求排名列表
JDBC 數(shù)據(jù)庫操作排名列表
5.3 函數(shù)調(diào)用棧分析
下圖是某個(gè)請求的函數(shù)調(diào)用棧分析
5.4 調(diào)用鏈跟蹤
下圖展示了一個(gè)請求在整個(gè)系統(tǒng)中的服務(wù)調(diào)用鏈以及相應(yīng)的時(shí)間分布席揽。
5.5 可自由定制的儀表盤
基礎(chǔ)操作系統(tǒng)的儀表盤
5.6 事件報(bào)警
下圖是一個(gè)事件報(bào)警的報(bào)告圖
6. 技術(shù)細(xì)節(jié)
6.1 Ease Agent
Ease Agent
是一種 Java Agent 顽馋,它在運(yùn)行時(shí)期間使用 java.lang.instrument
API 對特定方法進(jìn)行 字節(jié)碼增強(qiáng) ,以實(shí)現(xiàn)方法調(diào)用的上下文信息的采集幌羞,如:對于用戶請求的時(shí)間測量寸谜,函數(shù)調(diào)用棧的信息,分布式系統(tǒng)的調(diào)用鏈跟蹤新翎,等等程帕。
6.1.1 Design Principles
考慮到 Ease Agent
與宿主進(jìn)程運(yùn)行在同一個(gè) JVM 中,所以其 可靠性 和 弱干擾性 尤為重要地啰, 為此它被設(shè)計(jì)為:
-
獨(dú)立的 ClassLoader愁拭。 采用獨(dú)立的
ClassLoader
裝載自身字節(jié)碼,與宿主字節(jié)碼相隔離亏吝, 從而避免字節(jié)碼沖突岭埠。 - 精巧的裝載技術(shù)。 精巧的自定義裝載機(jī)制允許自身共享宿主已有字節(jié)碼, 大幅減少冗余字節(jié)碼的依賴惜论, 讓部署和運(yùn)行更為高效许赃。
- 高效的采樣技術(shù)。 多種調(diào)用采樣機(jī)制可供選擇馆类, 滿足不同場景下對于性能的苛刻要求混聊。
- 簡易的擴(kuò)展性。 內(nèi)建一套簡潔的 DSL 乾巧,令擴(kuò)展功能可在十來行代碼中得以實(shí)現(xiàn)句喜。
6.1.2 兼容性與要求
- 支持
Oracle JDK
或OpenJDK
6 到 8。 - 支持所有兼容
Java Servlet 3.0
的 Servlet 容器沟于, 如Tomcat
咳胃,Jetty
,JBoss
等旷太。 - 支持所有兼容 JDBC 的數(shù)據(jù)庫驅(qū)動(dòng)展懈,部分高級特性支持 MySQL (
mysql-connector-java v5.1.33
) - 支持
Apache HTTP Client v4.5.x
- 支持
Jedis v2.9.x
- 支持
Spring RestTemplate v4.x
- 支持
Zipkin v1.19.2+
6.1.3 采集數(shù)據(jù)種類
- 服務(wù)器收到 HTTP 請求的 Metric,以及調(diào)用關(guān)聯(lián)信息(如調(diào)用棧等)
- JDBC
Connection
獲取和Statement
執(zhí)行的 Metric供璧, 以及調(diào)用關(guān)聯(lián)信息(如 URL存崖,SQL等) - 兼容 Zipkin 協(xié)議的分布式調(diào)用鏈數(shù)據(jù),包括:
- HTTP 接收 與 發(fā)送
- SQL 執(zhí)行
- Redis 訪問
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ù)超過所配置的閾值,引發(fā)報(bào)警贞瞒。如:在兩分鐘內(nèi) cpu 利用率持續(xù)超過 80% 偶房。
指標(biāo) - 持續(xù)時(shí)間 - 百分比分布 - 閾值。 當(dāng)一個(gè)指標(biāo)在一個(gè)時(shí)間段間的某個(gè)百分比分布超過所配置的閾值军浆,引發(fā)報(bào)警棕洋。如:99%的請求響應(yīng)時(shí)間在兩分鐘內(nèi)超過 300ms (即:P99)
指標(biāo) - 持續(xù)時(shí)間 - 函數(shù) - 閾值。 支持一些簡單的函數(shù)計(jì)算 Sum/Average/Min/Max/Count乒融。如:在兩分鐘內(nèi) JVM 的 GC 次數(shù)超過所配置的閾值(使用Sum函數(shù))掰盘。
日志 - 持續(xù)時(shí)間 - 關(guān)鍵詞 - 匹配次數(shù)。監(jiān)控日志中某個(gè)關(guān)鍵詞在一個(gè)時(shí)間段內(nèi)出現(xiàn)的次數(shù)超過某個(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 文檔類型格式
我們有如下的文檔類型的存儲(chǔ)格式:
-
Index mapping template
-
ease-monitor-metrics-*
- 用于存儲(chǔ)時(shí)序類型的指標(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ù)種類邮偎。 -
platform
- 表明是平臺(tái)層中間件的數(shù)據(jù)種類管跺。如:nginx
,redis
,tomcat
,mysql
,kafka
... 等等。 -
infrastructure
- 表明是基礎(chǔ)層的數(shù)據(jù)種類禾进。如: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. |