前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >零基础学Flink:监控 on Prometheus

零基础学Flink:监控 on Prometheus

作者头像
麒思妙想
发布2020-07-10 10:14:08
1.8K0
发布2020-07-10 10:14:08
举报
文章被收录于专栏:麒思妙想麒思妙想

好久没更新Flink系列了,之前果然在Flink SQL 上淹死了,那部分暂时咕一段时间,等日后学有所成再补上,由于最近对普罗米修斯感兴趣,今天借机来说说监控吧,本文以推模式为例进行阐述的。对于监控有兴趣的同学,也可以移步到《Prometheus入门》去看看。

Pushgateway

前文并没有对,pushgateway进行介绍,下面来简述一下。

Pushgateway是 Prometheus 生态中一个重要工具,使用它的原因主要是:

  • Prometheus 采用 pull 模式,可能由于不在一个子网或者防火墙原因,导致 Prometheus 无法直接拉取各个 target 数据。
  • 在监控业务数据的时候,需要将不同数据汇总, 由 Prometheus 统一收集。

由于以上原因,不得不使用 pushgateway,但在使用之前,有必要了解一下它的一些弊端:

  • 将多个节点数据汇总到 pushgateway, 如果 pushgateway 挂了,受影响比多个 target 大。
  • Prometheus 拉取状态 up 只针对 pushgateway, 无法做到对每个节点有效。
  • Pushgateway 可以持久化推送给它的所有监控数据。

因此,即使你的监控已经下线,prometheus 还会拉取到旧的监控数据,需要手动清理 pushgateway 不要的数据。

拓扑图如下:

直接下安装包,放到prometheus的目录里即可,我实验用的环境是windows版本。

配置

flink部分

拷贝 opt目录下的flink-metrics-prometheus-X.X.X.jar 到lib目录。我这次flink环境用的1.9。

编辑conf/flink-conf.yml

metrics.reporter.promgateway.class: org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter

metrics.reporter.promgateway.host: localhost

metrics.reporter.promgateway.port: 9091

metrics.reporter.promgateway.jobName: myJob

metrics.reporter.promgateway.randomJobNameSuffix: true

metrics.reporter.promgateway.deleteOnShutdown: false

这里配置了要往Prometheus的9091端口推数据。

pushgateway

没有什么配置,直接启动就可以了,访问可以看到如下界面,表示配置成功

prometheus配置

scrape_configs:

- job_name: 'pushgateway'

static_configs:

- targets: ['localhost:9091']

labels:

instance: 'pushgateway'

在新增加一个job配置节,将pushgateway作为target配置进来。

然后分别启动flink 及 prometheus

在flink的界面里,看到相关监控信息已经配置进来了。

然后,可以在prometheus里看到相关指标里,当然也可以使用grafana来进行可视化监控。

参考连接:

https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/metrics.html#cpu

https://www.jianshu.com/p/fc9af91e6b07

https://www.cnblogs.com/xiao987334176/p/9933963.html

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-10-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 麒思妙想 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
大数据
全栈大数据产品,面向海量数据场景,帮助您 “智理无数,心中有数”!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档