首先请安装好prometheus、pushgateway以及grafana,如果还没安装请参考:
- Prometheus与pushGateway安装与使用
- Grafana安装指南
对hudi相关指标进行监控,只需要在将数据写入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监控指标介绍
相关指标查看从上述步骤中,我们可以看到其数据写入模式为insert,那么我们打开pushgateway,可以看到如下指标:
prometheus中可以看到:
而grafana通过接入prometheus中的数据,可进行展示:
而当数据停止写入到hudi中时,下述指标中的红线后部分,我们可以发现其趋于稳定:
注意事项某些指标在刚开始数据写入的时候并没有上报,需要等待一段时间。
了解更多



