实时数据相关

Prometheus 监控flink

2019-05-28  本文已影响10人  岳过山丘

提要

本文主要介绍将flink任务运行的metric发送到Prometheus

监控的意义

flink流式任务在实时性稳定性方面都有一定的要求,通过Prometheus 采集flink集群的metric,指定一些指标就可以对其进行监控告警。从而能够让开发人员快速反应,及时处理线上问题。

1.Prometheus 简介

Prometheus是一个开源的监控和报警系统。https://prometheus.io/docs/introduction/overview/

2.1特性

2.2组件

Prometheus生态系统包含很多组件(大多是都是可选择的)

2.3架构

下面这张图展示了prometheus的建构和prometheus系统可能需要到的组件:


image.png

3 flink集成prometheus

3.1 flink配置

详细配置参考
https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/metrics.html#cpu
进入flink目录

image.png
拷贝 opt目录下的flink-metrics-prometheus-1.7.2.jar 到lib目录。

编辑conf/flink-conf.yml

metrics.reporter.promgateway.class: org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter
metrics.reporter.promgateway.host: test01.cdh6.local
metrics.reporter.promgateway.port: 9091
metrics.reporter.promgateway.jobName: myJob
metrics.reporter.promgateway.randomJobNameSuffix: true
metrics.reporter.promgateway.deleteOnShutdown: false

3.2 pushgateway安装

参考 https://github.com/prometheus/pushgateway
访问 http://test01.cdh6.local:9091/#

image.png

3.3 prometheus安装

参考 https://www.jianshu.com/p/3a9ede07d963
本例prometheus和pushgateway安装到同一机器上
编写 prometheus.yml

scrape_configs:
  - job_name: 'pushgateway'
    static_configs:
      - targets: ['localhost:9091']
        labels:
          instance: 'pushgateway'

启动
./prometheus --config.file=prometheus.ym l
这个9091端口就是flink-conf.yml 对应的metrics.reporter.promgateway.port: 9091
flink会把一些metric push到9091端口上,然后prometheus采集。

4效果

启动flink集群 .bin/start-cluster.sh
访问 http://test01.cdh6.local:9090

image.png

总结

flink metric数据流转的流程是 flink metric -> pushgateway -> prometheus

todo 配置告警策略

上一篇 下一篇

猜你喜欢

热点阅读