Flink Metrics 簡介
Flink Metrics 是 Flink 集群運行中的各項指標,包含機器系統(tǒng)指標,比如:CPU、內(nèi)存、線程、JVM、網(wǎng)絡、IO、GC 以及任務運行組件(JM、TM、Slot、作業(yè)、算子)等相關(guān)指標。
Flink 一共提供了四種監(jiān)控指標:分別為 Counter、Gauge、Histogram、Meter。
Flink 主動方式共提供了 8 種 Report。
使用 PrometheusPushGatewayReporter 方式 通過 prometheus + pushgateway + grafana 組件搭建 Flink On Yarn 可視化監(jiān)控。
當 用戶 使用 Flink 通過 session 模式向 yarn 集群提交一個 job 后,F(xiàn)link 會通過 PrometheusPushGatewayReporter 將 metrics push 到 pushgateway 的 9091 端口上,然后使用外部系統(tǒng) prometheus 從 pushgateway 進行 pull 操作,將指標采集過來,通過 Grafana可視化工具展示出來。
2.1 配置 Reporter
鏈接:https://pan.baidu.com/s/1Bk0-3zLCK8Tn65QkIwVncw?
提取碼:qfob?
2.1.1 導包
將 flink-metrics-prometheus_2.11-1.13.2.jar 包導入 flink-1.13.2/bin 目錄下
2.1.2 配置 Reporter
選取 PrometheusPushGatewayReporter 方式,通過在官網(wǎng)查詢 Flink 1.13.2 Metrics 的配置后,在 flink-conf.yaml 設(shè)置,配置如下:
latency.metrics.interval: 60
metrics.reporter.promgateway.class:?org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter
metrics.reporter.promgateway.host:?IP地址A
metrics.reporter.promgateway.port:?9091
metrics.reporter.promgateway.jobName:?flink-metrics-ppg
metrics.reporter.promgateway.randomJobNameSuffix:?true
metrics.reporter.promgateway.deleteOnShutdown:?false
#metrics.reporter.promgateway.groupingKey:?k1=v1;k2=v2
#metrics.reporter.promgateway.interval:?60?SECONDS
2.2 部署 pushgateway
Pushgateway 是一個獨立的服務,Pushgateway 位于應用程序發(fā)送指標和 Prometheus 服務器之間。
Pushgateway 接收指標,然后將其作為目標被 Prometheus 服務器拉取??梢詫⑵淇醋鞔矸?,或者與 blackbox exporter 的行為相反,它接收度量,而不是探測它們。
2.2.1 解壓 pushgateway
2.2.2. 啟動 pushgateway
進入到 pushgateway-1.4.1 目錄下
./pushgateway?&
查看是否在后臺啟動成功
ps?aux|grep?pushgateway
2.2.3. 登錄 pushgateway webui
2.3 部署 prometheus.2.3. 登錄 pushgateway webui
Prometheus(普羅米修斯)是一個最初在 SoundCloud 上構(gòu)建的監(jiān)控系統(tǒng)。
2.3.1 解壓prometheus-2.30.0
2.3.2 編寫配置文件
scrape_configs:
??-?job_name:?'prometheus'
????static_configs:
??????-?targets:?['IP地址A:9090']
????????labels:
??????????instance:?'prometheus'
??-?job_name:?'linux'
????static_configs:
??????-?targets:?['IP地址A:9100']
????????labels:
??????????instance:?'localhost'
??-?job_name:?'pushgateway'
????static_configs:
??????-?targets:?['IP地址A:9091']
????????labels:
??????????instance:?'pushgateway'
2.3.3 啟動prometheus
./prometheus?--config.file=prometheus.yml?&
啟動完后,可以通過 ps 查看一下端口
ps aux|grep prometheus
2.3.4 登錄prometheus webui
2.4 部署 grafana
Grafana 是一個跨平臺的開源的度量分析和可視化工具,可以通過將采集的數(shù)據(jù)查詢?nèi)缓罂梢暬恼故?/span>
2.4.1 解壓grafana-8.1.5
?
2.4.2 啟動grafana-8.1.5?????
./bin/grafana-server web &
2.4.3 登錄 grafana
登錄用戶名和密碼都是 admin
grafana 配置中文教程:
Prometheus data source | Grafana documentation
2.4.4 配置數(shù)據(jù)源、創(chuàng)建系統(tǒng)負載監(jiān)控
要訪問 Prometheus 設(shè)置,請將鼠標懸停在配置(齒輪)圖標上,然后單擊數(shù)據(jù)源,然后單擊 Prometheus 數(shù)據(jù)源,根據(jù)下圖進行操作。
?操作完成后,點擊進行驗證。
2.4.5 添加儀表盤
點擊最左側(cè) + 號,選擇 DashBoard,選擇新建一個 pannel
?
至此,F(xiàn)link 的 metrics 的指標展示在 Grafana 中了
使用 Lateny marker,所有需要在 flink-conf.yaml 配置參數(shù)
latency.metrics.interval
系統(tǒng)配置截圖如下:
全鏈路吞吐計算方式 :
全鏈路吞吐 = 單位時間處理數(shù)據(jù)數(shù)量 單位時間
提交任務到Flink on Yarn集群
#?-m?jobmanager?的地址
#?-yjm?1024?指定?jobmanager?的內(nèi)存信息
#?-ytm?1024?指定?taskmanager?的內(nèi)存信息
bin/flink?run?\
-t?yarn-per-job?-yjm?4096?-ytm??8800?-s?96??\
--detached??-c?com.threeknowbigdata.datastream.XgboostModelPrediction?\
examples/batch/WordCount.jar??\
輸入14911,點擊Load
這個14911是一個其他人發(fā)布的一個Dashboard。這個id是從Grafana官方提供的Dashboard網(wǎng)站 https://grafana.com/grafana/dashboards/ 里找到的。以后要添加其他類型的比如flink或者mysql監(jiān)控報表,都可以從這個網(wǎng)站找到。
如果成功就可以看到如下界面,默認都是折疊的文章來源:http://www.zghlxwxcb.cn/news/detail-592000.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-592000.html
到了這里,關(guān)于Flink Metrics監(jiān)控 pushgateway搭建的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!