Skip to content

[FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric values#27743

Open
mukul-8 wants to merge 1 commit intoapache:masterfrom
mukul-8:FLINK-38704-numeric-config-properties
Open

[FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric values#27743
mukul-8 wants to merge 1 commit intoapache:masterfrom
mukul-8:FLINK-38704-numeric-config-properties

Conversation

@mukul-8
Copy link

@mukul-8 mukul-8 commented Mar 6, 2026

What is the purpose of the change

Fixes the Prometheus metrics reporter (and potentially other reporters) not loading configured port values.

The issue occurs because numeric YAML configuration values are stored as Integer/Long objects, but Properties.getProperty() only returns Strings. When MetricConfig.getString() is called for numeric values like metrics.reporter.prom.port, it returns null, causing reporters to fall back to default values.

Note: The bug only reproduces when a single number is assigned to the port (e.g., 9999). It works correctly when a port-range is used (e.g., 9000-9100) because ranges are stored as Strings.

Workaround: Quote the port value in YAML configuration: metrics.reporter.prom.port: "9999"

Brief change log

  • Changed MetricConfig.getString() to use get() instead of getProperty(), matching the pattern of getInteger(), getLong(), etc. Added test cases to verify the fix.

Verifying this change

This change fixes the bug where:

  • Configuration loads: metrics.reporter.prom.port=9999
  • But reporter starts on default port 9249 instead

After the fix, the configured port is correctly applied.

Added test case to verify this change is working fine.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Mar 6, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@mukul-8 mukul-8 requested a review from davidradl March 9, 2026 12:11
… values

MetricConfig.getString() was using getProperty() which returns null for
numeric YAML values stored as Integer/Long/Boolean. Changed to use get()
and convert to String, matching the pattern of other getter methods.

This fixes metrics reporters not loading numeric configuration values.
@mukul-8 mukul-8 force-pushed the FLINK-38704-numeric-config-properties branch from e99c20c to 0d5ca17 Compare March 10, 2026 06:21
@mukul-8 mukul-8 changed the title [FLINK-38704][runtime] Convert config values to String [FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric values Mar 10, 2026
@mukul-8
Copy link
Author

mukul-8 commented Mar 10, 2026

Updated the fix. Instead of converting values in DelegatingConfiguration, I fixed the root cause in MetricConfig.getString() to use get() instead of getProperty(), matching the pattern of other getter methods. This preserves compatibility with Python tests while fixing the metrics reporter issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants