Repository navigation
[FLINK-41054][metrics] Add exclude filter for the metric query service - #29564
Open
ctrlaltdilj wants to merge 1 commit into
Open
ctrlaltdilj wants to merge 1 commit into
ctrlaltdilj wants to merge 1 commit into
Conversation
The JobManager's MetricStore only ever adds metrics, so metrics scoped by a dynamically created group accumulate until the job is removed. The per-split watermark metrics of sources are keyed by split id and therefore grow without bound in the REST API (e.g. /subtasks/metrics), even though the TaskManager side closes the split metric group once the split finishes. Introduce metrics.internal.query-service.filter.excludes, which uses the same filter syntax as the reporter filters and is applied before a metric is handed to the MetricQueryService. Excluded metrics are still reported to metric reporters, which receive proper unregister notifications. The option defaults to excluding the split watermark metrics; an empty value exposes everything again. Generated-by: Claude Code (Claude Fable 5.1)
ctrlaltdilj
force-pushed
the
FLINK-41054-query-service-filter
branch
from
October 22, 2026 10:10
6bea443 to
b834708
Compare
Collaborator
Author
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
The JobManager's
MetricStoreonly ever adds metrics; entries are retained until the job is removed. Metrics registered under a dynamically created group therefore accumulate indefinitely in the REST API. The per-split watermark metrics introduced by FLIP-513 are keyed by split id, so for sources with many splits/jobs/:jobid/vertices/:vertexid/subtasks/metricskeeps returning entries for every split the source has ever read, even though the TaskManager side closes the split metric group once the split finishes (FLINK-37596, FLINK-40549).This PR introduces
metrics.internal.query-service.filter.excludes, a filter applied before a metric is handed to theMetricQueryService. It mirrors the existing per-reporterfilter.excludessyntax. Excluded metrics are still delivered to metric reporters, which receive proper unregister notifications and are therefore unaffected by the leak. The option defaults to excluding the split watermark metrics (*.operator.split.watermark:*:*); an empty value exposes them again.This is a mitigation for the specific unbounded case rather than a fix of the add-only
MetricStore. Fixing the store to drop metrics that no longer appear in a TaskManager dump is a larger change that can be tracked separately.Brief change log
MetricOptions.QUERY_SERVICE_EXCLUDES(metrics.internal.query-service.filter.excludes), a list option using the reporter filter format, defaulting to the split watermark scope.DefaultReporterFilters.queryServiceMetricsFromConfiguration, which builds aReporterFilter<Metric>with an implicit include-all and the configured excludes.MetricRegistryConfigurationparses the filter once at startup, logs the resolved exclude list at INFO, and falls back to the default with a WARN if the value cannot be parsed.MetricRegistryImpl.registerevaluates the filter against the metric's logical scope before callingMetricQueryService.addMetric. Reporter notification and unregistration are unchanged.metric_configuration.html) and note on the Split metrics table indocs/content/docs/ops/metrics.mdthat these metrics reach reporters only by default.Verifying this change
This change added tests and can be verified as follows:
MetricRegistryImplTest#testQueryServiceExcludesSplitWatermarkMetricsByDefaultregisters a gauge under a realtaskmanager.job.task.operator.split.watermarkgroup hierarchy and asserts that a reporter receives it while the query service dump does not.MetricRegistryImplTest#testQueryServiceExcludesAreConfigurableasserts that a configured pattern excludes a matching metric from the query service dump while others remain.DefaultReporterFiltersTest#testQueryServiceFilterExcludesSplitWatermarkMetricsByDefaultand#testQueryServiceFilterFromConfigurationcover the default filter, multiple entries, type-scoped entries, and that a configured list replaces the default rather than extending it.DefaultReporterFiltersTest#testQueryServiceFilterWithoutExcludesExposesSplitWatermarkMetricscovers both the empty list and the empty flat string form.ConfigOptionsDocsCompletenessITCasepasses against the regenerated documentation.Does this pull request potentially affect one of the following parts:
@Public(Evolving): yes, a new option is added toMetricOptions(@PublicEvolving). No existing option or signature changes.Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Fable 5.1)