零基础学Flink:监控 on Prometheus

好久没更新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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

麒思妙想

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值