前提
首先請安裝好prometheus、pushgateway以及grafana,如果還沒安裝請參考:
Prometheus與pushGateway安裝與使用 (連結:https://www。lrting。top/tools/prometheus-and-pushgateway-install。html)
Grafana安裝指南(連結:https://www。lrting。top/tools/grafana-install-overview。html)
對hudi相關指標進行監控,只需要在將資料寫入hudi的時候進行監控配置即可,本文以文章
Flink SQL Client實戰CDC資料入hudi資料湖
為例,對其指標進行監控。文章地址:Flink SQL Client實戰CDC資料入湖 | 從大資料到人工智慧
基本環境介紹
本問是用的prometheus、pushgateway以及grafana的地址和埠分別為:
promotheus:hadoop1:9090
pushgateway:hadoop1:9091
grafana:windows安裝的程式,直接接入prometheus資料
本問是用的示例與Flink SQL Client實戰CDC資料入湖文章所述基本一致,只是在建立hudi目標表有所不同,並且原來的表名為stu3全部換成stu6。接下來直接從如何建立帶有監控引數的hudi目標表。
建立帶有監控引數的hudi目標表
create table stu6_binlog_sink_hudi( id bigint not null, name string, `school` string, nickname string, age int not null, class_num int not null, phone bigint not null, email string, ip string, primary key (id) not enforced) partitioned by (`school`) with ( ‘connector’ = ‘hudi’, ‘path’ = ‘hdfs://hadoop:9000/tmp/stu6_binlog_sink_hudi’, ‘table。type’ = ‘MERGE_ON_READ’, ‘write。option’ = ‘insert’, ‘write。precombine。field’ = ‘school’, ‘hoodie。metrics。on’ = ‘true’, ‘hoodie。metrics。executor。enable’ = ‘true’, ‘hoodie。metrics。reporter。type’ = ‘PROMETHEUS_PUSHGATEWAY’, ‘hoodie。metrics。pushgateway。job。name’ = ‘hudi-metrics’, ‘hoodie。metrics。pushgateway。host’ = ‘hadoop1’, ‘hoodie。metrics。pushgateway。report。period。seconds’ = ‘10’, ‘hoodie。metrics。pushgateway。delete。on。shutdown’ = ‘false’, ‘hoodie。metrics。pushgateway。random。job。name。suffix’ = ‘false’ );
相比原文,本文在建立hudi目標表時候新增了hoodie。metrics。_相關指標,具體指標含義可參考:hudi監控指標介紹,地址:https://hudi。apache。org/docs/configurations/#METRICS
相關指標檢視
從上述步驟中,我們可以看到其資料寫入模式為insert,那麼我們開啟pushgateway,可以看到如下指標:
prometheus中可以看到:
而grafana透過接入prometheus中的資料,可進行展示:
而當資料停止寫入到hudi中時,下述指標中的紅線後部分,我們可以發現其趨於穩定:
注意事項
某些指標在剛開始資料寫入的時候並沒有上報,需要等待一段時間。