Flink Metric Reporters 实战统一配置模型、过滤规则、Push/Pull、Tags/Identifier 与常用 Reporter 模板
1. Reporter 是怎么工作的在flink-conf.yaml配置metrics.reporters指定启用哪些 reporter每个 reporter 都要配置metrics.reporter.name.factory.classPush 型 reporter 还可以配置metrics.reporter.name.interval以控制上报周期Reporter jar 必须在 Flink 启动时可见Reporter以插件方式加载Flink 文档中的 reporter 通常默认可用2. 两个关键维度Identifier vs TagsPush vs Pull2.1 Identifier-based标识符型把 scope 信息和指标名拼成一个扁平字符串例如job.MyJobName.numRestarts典型Graphite、StatsD、Slf4j偏 identifier2.2 Tag-based标签型把“逻辑指标类”与“实例标签”分开例如逻辑指标job.numRestarts标签jobNameMyJobName典型Prometheus、InfluxDB、Datadog偏 tags2.3 Push vs PullPushReporter 定期主动发给外部系统需要 intervalPull外部系统来抓取/查询Prometheus/JMX 常见3. 通用配置参数所有 reporter 都能用的那套配置格式统一为metrics.reporter.reporter_name.property通用 Key最常用的几项factory.class必配指定 ReporterFactoryinterval默认 10s仅 Push 型生效scope.delimiter拼接 metric identifier 的分隔符默认.scope.variables.additional给 tag 型 reporter 增加额外标签mapscope.variables.excludes排除某些变量tag 型filter.includes/filter.excludes指标过滤强烈建议用来控量3.1 多 reporter 并存示例metrics.reporters:my_jmx_reporter,my_other_reportermetrics.reporter.my_jmx_reporter.factory.class:org.apache.flink.metrics.jmx.JMXReporterFactorymetrics.reporter.my_jmx_reporter.port:9020-9040metrics.reporter.my_other_reporter.factory.class:org.apache.flink.metrics.graphite.GraphiteReporterFactorymetrics.reporter.my_other_reporter.host:192.168.1.1metrics.reporter.my_other_reporter.port:100004. 过滤器filter.includes/excludes写对了能省一大半成本过滤器格式一个字符串就是一个 filterscope[:name[,name][:type[,type]]]scope逻辑范围用.分段*通配name指标名模式逗号分隔*通配type指标类型counter,meter,gauge,histogram匹配规则一个指标命中 filter 需要同时满足scope 匹配name 至少一个模式匹配type 至少一个类型匹配4.1 常见例子你直接拿去改全局匹配某类指标名metrics.reporter.prom.filter.includes:*:numRecords*只要 operator 层的 numRecords 指标metrics.reporter.prom.filter.includes:*.job.task.operator:numRecords*只要 operator 层的 meter如 numRecordsInPerSecondmetrics.reporter.prom.filter.includes:*.job.task.operator:numRecords*:meter只要 Records/Bytes 相关的 counter metermetrics.reporter.prom.filter.includes:*:*Records*,*Bytes*:counter,meter生产建议Prometheus/Datadog/InfluxDB 这类 tags 报表很容易“标签爆炸”务必用过滤器控制输出范围否则指标量和成本会快速失控。5. 常用 Reporter 配置模板与注意点下面把文档里几个最常用的 reporter 配置按“可直接复制”方式整理出来。5.1 JMXpull / tags适合 JVM 生态排障、用 JConsole/JMC 或被采集系统抓取。metrics.reporter.jmx.factory.class:org.apache.flink.metrics.jmx.JMXReporterFactorymetrics.reporter.jmx.port:9250-9260建议用端口范围同一台机器上可能同时有 JM/TM避免端口冲突实际绑定端口会在日志里打印。5.2 Prometheuspull / tags最常用的云原生采集方式。metrics.reporter.prom.factory.class:org.apache.flink.metrics.prometheus.PrometheusReporterFactorymetrics.reporter.prom.port:9250-9260# 可选标签值字符过滤默认 true# metrics.reporter.prom.filterLabelValueCharacters: true类型映射注意点很实用Flink Counter → Prometheus Gauge因为 Prometheus counter 不允许递减Histogram → Summary带固定 quantilesMeter → Gauge输出 rate5.3 Prometheus PushGatewaypush / tags适合“短生命周期任务”或无法被 Prometheus 直连抓取的环境。metrics.reporter.promgateway.factory.class:org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporterFactorymetrics.reporter.promgateway.hostUrl:http://localhost:9091metrics.reporter.promgateway.jobName:myJobmetrics.reporter.promgateway.randomJobNameSuffix:truemetrics.reporter.promgateway.deleteOnShutdown:falsemetrics.reporter.promgateway.groupingKey:k1v1;k2v2metrics.reporter.promgateway.interval:60 SECONDS5.4 InfluxDBpush / tags适合时序库落库分析。metrics.reporter.influxdb.factory.class:org.apache.flink.metrics.influxdb.InfluxdbReporterFactorymetrics.reporter.influxdb.scheme:httpmetrics.reporter.influxdb.host:localhostmetrics.reporter.influxdb.port:8086metrics.reporter.influxdb.db:flinkmetrics.reporter.influxdb.username:flink-metricsmetrics.reporter.influxdb.password:qwertymetrics.reporter.influxdb.retentionPolicy:one_hourmetrics.reporter.influxdb.consistency:ANYmetrics.reporter.influxdb.connectTimeout:60000metrics.reporter.influxdb.writeTimeout:60000metrics.reporter.influxdb.interval:60 SECONDS5.5 Graphitepush / identifiermetrics.reporter.grph.factory.class:org.apache.flink.metrics.graphite.GraphiteReporterFactorymetrics.reporter.grph.host:localhostmetrics.reporter.grph.port:2003metrics.reporter.grph.protocol:TCPmetrics.reporter.grph.interval:60 SECONDS5.6 StatsDpush / identifiermetrics.reporter.stsd.factory.class:org.apache.flink.metrics.statsd.StatsDReporterFactorymetrics.reporter.stsd.host:localhostmetrics.reporter.stsd.port:8125metrics.reporter.stsd.interval:60 SECONDS5.7 Datadogpush / tags兼有 identifierDatadog 会把 host/job_name/tm_id/subtask_index/task_name/operator_name 等作为 tags 上报。metrics.reporter.dghttp.factory.class:org.apache.flink.metrics.datadog.DatadogHttpReporterFactorymetrics.reporter.dghttp.apikey:xxxmetrics.reporter.dghttp.proxyHost:my.web.proxy.commetrics.reporter.dghttp.proxyPort:8080metrics.reporter.dghttp.dataCenter:USmetrics.reporter.dghttp.maxMetricsPerRequest:2000metrics.reporter.dghttp.interval:60 SECONDSmetrics.reporter.dghttp.useLogicalIdentifier:true注意Histogram 会以一组 gauge 的形式上报如metric.aggregation并且聚合并非基于每个上报周期重新计算的那种“区间聚合”理解这一点很重要。5.8 OpenTelemetryOtel适合统一接入观测体系Collector → 多后端。metrics.reporter.otel.factory.class:org.apache.flink.metrics.otel.OpenTelemetryMetricReporterFactorymetrics.reporter.otel.exporter.endpoint:http://127.0.0.1:1337metrics.reporter.otel.exporter.protocol:gRPC# 可选# metrics.reporter.otel.exporter.timeout: 10s# metrics.reporter.otel.service.name: flink# metrics.reporter.otel.service.version: 1.0.0HTTP 协议的写法metrics.reporter.otel.factory.class:org.apache.flink.metrics.otel.OpenTelemetryMetricReporterFactorymetrics.reporter.otel.exporter.endpoint:http://127.0.0.1:9090metrics.reporter.otel.exporter.protocol:HTTP5.9 Slf4jpush / identifier适合调试或小规模环境不建议大集群长期打开日志量会爆。metrics.reporter.slf4j.factory.class:org.apache.flink.metrics.slf4j.Slf4jReporterFactorymetrics.reporter.slf4j.interval:60 SECONDS6. 自定义 Reporter两条接口要点实现org.apache.flink.metrics.reporter.MetricReporter如果要定期上报实现Scheduled接口report()方法不要长时间阻塞耗时操作建议异步化再实现MetricReporterFactory就能以插件方式加载也更符合 Flink 插件隔离机制7. 一套“生产默认建议”不引战但很实用云原生/K8s优先 Prometheuspull/tags端口用范围配 filter 控量需要落库分析InfluxDB/Otel → 统一收敛遗留体系Graphite/StatsD 仍可用但 identifier 模式要注意命名层级规划任何 tags 系统谨防标签爆炸scope.variables filter 是关键

相关新闻

从自测到部署:DMXAPI如何为AI编程提供全方位的技术保障?

从自测到部署:DMXAPI如何为AI编程提供全方位的技术保障?

前言:AI编程的“死亡之谷”与技术护城河2026年,全球AI应用开发成功率出现了一个令人深思的数据:从概念验证到生产部署,仅有18%的AI项目能够成功跨越这个“死亡之谷”。那些失败的82%,并非因为创意不足或技术不先进&…

2026/5/17 3:35:23 阅读更多 →
洪水区域检测数据集含有部分普通无人机视角航拍洪水检测数据集 洪涝灾害监测、智慧城市应急响应、遥感影像分析 YOLOV11模型如何训练洪水自然灾害检测数据

洪水区域检测数据集含有部分普通无人机视角航拍洪水检测数据集 洪涝灾害监测、智慧城市应急响应、遥感影像分析 YOLOV11模型如何训练洪水自然灾害检测数据

洪水区域检测数据集含有部分普通无人机视角航拍洪水检测数据集类别数量格式洪水区域(flood_area)、积水区(ponding_area)图像2153张,数据集17个,模型6个计算机视觉目标检测数据集(基于yolov11/y…

2026/5/17 3:35:21 阅读更多 →
深入浅出LangChain4J

深入浅出LangChain4J

1.走进LangChain 1.1.什么是LangChain4J? The goal of LangChain4J is to simplify integrating LLMs into Java applications. ​ -- 《LangChain4J Doc》 LangChain4J就像Java的Spring框架一样,为LLM的接入提供了一套标准的接入能力。LangChain4J是La…

2026/7/4 22:03:41 阅读更多 →

最新新闻

Gemma-4 E4B技术深度解析:如何用4.5B有效参数实现多模态智能

Gemma-4 E4B技术深度解析:如何用4.5B有效参数实现多模态智能

Gemma-4 E4B技术深度解析:如何用4.5B有效参数实现多模态智能 【免费下载链接】gemma-4-E4B 项目地址: https://ai.gitcode.com/hf_mirrors/google/gemma-4-E4B 当你面对一个需要同时处理文本、图像、音频和视频的AI项目时,是否曾为选择合适模型而…

2026/7/5 15:56:41 阅读更多 →
Vue3企业级数据可视化大屏架构设计:应对多分辨率适配与实时渲染挑战

Vue3企业级数据可视化大屏架构设计:应对多分辨率适配与实时渲染挑战

Vue3企业级数据可视化大屏架构设计:应对多分辨率适配与实时渲染挑战 【免费下载链接】IofTV-Screen-Vue3 一个基于 vue3、vite、Echart 框架的大数据可视化(大屏展示)模板 项目地址: https://gitcode.com/gh_mirrors/io/IofTV-Screen-Vue3 …

2026/7/5 15:56:41 阅读更多 →
Gin-Vue-Admin代码生成器字段编辑:5个深度优化技巧与架构解析

Gin-Vue-Admin代码生成器字段编辑:5个深度优化技巧与架构解析

Gin-Vue-Admin代码生成器字段编辑:5个深度优化技巧与架构解析 【免费下载链接】gin-vue-admin 🚀ViteVue3Gin的开发基础平台,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下…

2026/7/5 15:54:41 阅读更多 →
3分钟掌握 facetype.js:终极字体转换工具完全指南

3分钟掌握 facetype.js:终极字体转换工具完全指南

3分钟掌握 facetype.js:终极字体转换工具完全指南 【免费下载链接】facetype.js typeface.js generator 项目地址: https://gitcode.com/gh_mirrors/fa/facetype.js facetype.js 是一个强大的在线字体转换工具,专门用于将标准字体文件转换为 type…

2026/7/5 15:54:41 阅读更多 →
DINOv3:重新定义视觉基础模型的无监督学习范式

DINOv3:重新定义视觉基础模型的无监督学习范式

DINOv3:重新定义视觉基础模型的无监督学习范式 【免费下载链接】dinov3 Reference PyTorch implementation and models for DINOv3 项目地址: https://gitcode.com/GitHub_Trending/di/dinov3 在计算机视觉领域,大规模预训练模型正经历着从监督学…

2026/7/5 15:54:41 阅读更多 →
Perlite研究应用:学术笔记管理与分享系统的终极指南

Perlite研究应用:学术笔记管理与分享系统的终极指南

Perlite研究应用:学术笔记管理与分享系统的终极指南 【免费下载链接】Perlite A web-based markdown viewer optimized for Obsidian 项目地址: https://gitcode.com/GitHub_Trending/pe/Perlite Perlite是一个基于Web的Markdown查看器,专为Obsid…

2026/7/5 15:50:40 阅读更多 →

日新闻

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容 【免费下载链接】BiliTools A cross-platform bilibili toolbox. 跨平台哔哩哔哩工具箱,支持下载视频、番剧等等各类资源 项目地址: https://gitcode.com/GitHub_Trending/bilit/BiliTools …

2026/7/5 0:03:34 阅读更多 →
威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型的陌生现状在忙碌疲惫的一天里,参与了关于混合后量子密码学的讨论,应付端点攻击找茬的人,还参与留言板讨论后,发现“威胁模型”对多数人仍是陌生概念,且多被当作时髦用语。有趣的相关画作有一幅由 Embyr 创作的…

2026/7/5 0:03:34 阅读更多 →
渗透测试入门指南:从零基础到实战环境搭建

渗透测试入门指南:从零基础到实战环境搭建

1. 从“看热闹”到“入门”:我理解的渗透测试到底是什么?每次看到新闻里说某个大公司的数据被“黑”了,或者某个网站被攻击导致服务瘫痪,你是不是和我一样,心里会冒出两个念头:一是“这黑客真厉害”&#x…

2026/7/5 0:07:38 阅读更多 →

周新闻

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容 【免费下载链接】BiliTools A cross-platform bilibili toolbox. 跨平台哔哩哔哩工具箱,支持下载视频、番剧等等各类资源 项目地址: https://gitcode.com/GitHub_Trending/bilit/BiliTools …

2026/7/5 0:03:34 阅读更多 →
威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型的陌生现状在忙碌疲惫的一天里,参与了关于混合后量子密码学的讨论,应付端点攻击找茬的人,还参与留言板讨论后,发现“威胁模型”对多数人仍是陌生概念,且多被当作时髦用语。有趣的相关画作有一幅由 Embyr 创作的…

2026/7/5 0:03:34 阅读更多 →
渗透测试入门指南:从零基础到实战环境搭建

渗透测试入门指南:从零基础到实战环境搭建

1. 从“看热闹”到“入门”:我理解的渗透测试到底是什么?每次看到新闻里说某个大公司的数据被“黑”了,或者某个网站被攻击导致服务瘫痪,你是不是和我一样,心里会冒出两个念头:一是“这黑客真厉害”&#x…

2026/7/5 0:07:38 阅读更多 →

月新闻