fix: Relax metric name validation in Dropwizard5#1985
Open
LiamClarkeNZ wants to merge 1 commit intoprometheus:mainfrom
Open
fix: Relax metric name validation in Dropwizard5#1985LiamClarkeNZ wants to merge 1 commit intoprometheus:mainfrom
LiamClarkeNZ wants to merge 1 commit intoprometheus:mainfrom
Conversation
The MapperConfig and GraphiteNamePattern classes enforced Graphite-style dot-separated naming conventions on input metrics, preventing the CustomMappingSampleBuilder from remapping metrics with underscores, colons, or single-level names. Relaxes the validation regex to accept a broader range of metric name patterns while still rejecting clearly invalid inputs. Fixes prometheus#461, prometheus#518, prometheus#645 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Liam Clarke-Hutchinson <liam@steelsky.co.nz>
0c81193 to
6746915
Compare
jaydeluca
approved these changes
Mar 29, 2026
Collaborator
jaydeluca
left a comment
There was a problem hiding this comment.
knocking out 3 issues in one PR, going for the hat-trick! 😄
just one small nitpick comment but otherwise LGTM
| // Simplified GLOB: we can have "*." at the beginning and "*" only at the end | ||
| // Each part of the metric name between dots. Accepts letters, digits, underscores, hyphens, | ||
| // colons, and glob wildcards (*) to support a broad range of metric naming conventions. | ||
| private static final String METRIC_PART_REGEX = "[a-zA-Z_0-9*][a-zA-Z0-9_:\\-*]*"; |
Collaborator
There was a problem hiding this comment.
moving the hyphen to the end removes the need to escape it
Suggested change
| private static final String METRIC_PART_REGEX = "[a-zA-Z_0-9*][a-zA-Z0-9_:\\-*]*"; | |
| private static final String METRIC_PART_REGEX = "[a-zA-Z_0-9*][a-zA-Z0-9_:*-]*"; |
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.
Decided to revisit a very old PR of mine that addressed an issue that seems to reoccur periodically for others.
Changes
METRIC_GLOB_REGEXinMapperConfig/GraphiteNamePatternto accept a broader range of metric name patternsCustomMappingSampleBuildercan now remap metrics with underscores, colons, hyphens, and single-level namesFixes
:in regexThe validation was originally designed for Graphite bridge metrics but is too restrictive for
CustomMappingSampleBuilderwhich needs to handle arbitrary Dropwizard metric names.@fstab @dhoard @zeitlinger @jaydeluca when you have a chance would appreciate your review :)