栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Prometheus+Grafana集成监控Flink

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Prometheus+Grafana集成监控Flink

文章目录
  • 前言
  • 一、技术介绍
    • 1、Prometheus
    • 2、Grafana
    • 3、架构图
  • 二、安装步骤
      • 1、拷贝jar包
      • 2、修改 Flink 配置
      • 3、pushgateway安装
      • 4、node_exporter安装
      • 5、prometheus安装
      • 6、grafana安装
  • 总结


前言

使用Prometheus+Grafana对Flink进行监控

一、技术介绍 1、Prometheus

Prometheus是一套开源的系统监控报警框架。它受启发于Google的Brogmon监控系统,由工作在SoundCloud的前google员工在2012年创建,作为社区开源项目进行开发,并于 2015年正式发布。

2016年,Prometheus正式加入Cloud Native Computing Foundation(CNCF)基金会的项目,成为受欢迎度仅次于Kubernetes 的项目。2017年底发布了基于全新存储层的2.0版本,能更好地与容器平台、云平台配合。和展示工具Grafana有很好的集成性。

prometheus项目地址:https://github.com/prometheus/prometheus
pushgateway项目地址:https://github.com/prometheus/pushgateway

2、Grafana

Grafana是一款用Go语言开发的开源数据可视化工具,可以做数据监控和数据统计,带有告警功能。

项目地址:https://github.com/grafana/grafana

3、架构图


Flink App :需要监控的数据来源
Prometheus :收集数据
nodeManger :Prometheus 生态中的组件,nodeMnager负责监控运行机器的状态
Pushgateway:Prometheus 生态中的组件,pushGateway服务收集Flink的指标
Grafana :进行可视化展示

二、安装步骤

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

1、拷贝jar包

将flink中plugins文件夹下的jar拷贝至lib目录下

cd plugins/metrics-prometheus/
cp flink-metrics-prometheus-1.13.0.jar /data/flink-1.13.0/lib/
2、修改 Flink 配置
cd conf/
vi flink-conf.yaml

修改如下

##### 与 Prometheus 集成配置 #####
metrics.reporter.promgateway.class: 
org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter
# PushGateway 的主机名与端口号
metrics.reporter.promgateway.host: localhost
metrics.reporter.promgateway.port: 9091
# Flink metric 在前端展示的标签(前缀)与随机后缀
metrics.reporter.promgateway.jobName: myJob
metrics.reporter.promgateway.randomJobNameSuffix: true
metrics.reporter.promgateway.deleteOnShutdown: false
metrics.reporter.promgateway.interval: 30 SECONDS
3、pushgateway安装

下载:https://prometheus.io/download/
解压:tar -zxvf pushgateway-0.9.1.linux-amd64.tar.gz
启动:./pushgateway
访问:http://localhost:9091/

4、node_exporter安装

下载:https://prometheus.io/download/
解压:tar -zxvf node_exporter-1.3.1.linux-amd64.tar.gz
启动:./node_exporter
访问:http://localhost:9100/metrics

5、prometheus安装

下载:https://prometheus.io/download/
解压:tar -zxvf prometheus-2.36.0-rc0.linux-amd64.tar.gz
编辑 prometheus.yml

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: 'prometheus'
  - job_name: 'linux'
    static_configs:
      - targets: ['localhost:9100']
        labels:
          instance: 'localhost'
  - job_name: 'pushgateway'
    static_configs:
      - targets: ['localhost:9091']
        labels:
          instance: 'pushgateway'

启动:./prometheus --config.file=prometheus.yml
访问:http://localhost:9090/targets

6、grafana安装

下载:wget https://dl.grafana.com/oss/release/grafana-6.3.6.linux-amd64.tar.gz
解压:tar -zxvf grafana-6.3.6.linux-amd64.tar.gz
启动:./bin/grafana-server web
访问:http://localhost:3000/login
查看进程:netstat -apn | grep -E ‘9091|3000|9090|9100’
操作步骤:

  1. 点击Add data source
  2. 点击Prometheus
  3. 输入URL地址,点击保存
  4. 点击New dashbpoard
  5. 点击Add Quary
  6. 如下操作,成功显示
总结

至此搭建完成,感谢阅读。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/939017.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号