实时作业要保证7 x 24运行,除了要在业务逻辑和编码上下功夫之外,好的监控系统也是必不可少的。Flink支持多种汇报监控指标(metrics)的reporter,如JMX、SLF4J、InfluxDB、Prometheus等。
这里我们选择Prometheus+grafana,下面我们线给出一个架构图
下面讲述一下配置过程
1.pushGateway的安装
从上图可知,Prometheus是从pushgateway拉取数据的,但是flink on yarn作业的每一个任务对应的集群不一样,地址不一样,那么对于Prometheus这样一个主动拉取的角色,就必须借助一个固定地址的数据中转站来进行数据的获取,pushgateway就具有类似的功能
首先我们根据flink版本,获取对应的flink-metrics包
|
下载pushGateway的安装包
wget https://github.com/prometheus/pushgateway/releases/download/v1.4.1/pushgateway-1.4.1.darwin-amd64.tar.gz
pushgateway启动
nohup ./pushgateway --web.listen-address :9091 &
2.Promethus的安装
Promethus安装包下载
wget https://github.com/prometheus/prometheus/releases/download/v2.29.0-rc.2/prometheus-2.29.0-rc.2.darwin-amd64.tar.gz
Promethus配置
- job_name :'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets : [ 'localhost:9090' ]
labels:
instance: prometheus
- job_name : 'pushgateway'
static_configs:
- targets : [ 'localhost:9091' ]
labels:
instance: pushgateway
启动:
nohup ./prometheus --config.file=prometheus.yml &
3.grafana的安装配置
wget https://dl.grafana.com/oss/release/grafana-8.1.0.darwin-amd64.tar.gz
启动
nohup ./bin/grafana-server web &
4.启动flink
前提是准备好mysql/hadoop/hive metastore的环境
flink配置
|
启动yarn-session
bin/yarn-session.sh -d
bin/sql-client.sh -i init.sql
insert into flink_test select *,DATE_FORMAT(birthday, 'yyyyMMdd') from mysql_users
查看flink的web页面
查看grafana的页面