-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix metric rule pattern regex #12856
Fix metric rule pattern regex #12856
Conversation
Can you please elaborate more on this? Maybe you can use an example to explain why it is needed? |
@@ -1,173 +1,173 @@ | |||
rules: | |||
- pattern: "\"org.apache.pinot.common.metrics\"<type=\"BrokerMetrics\", name=\"pinot.broker.(([^\\.]+)\\.)?([^\\.]*?).authorization\"><>(\\w+)" | |||
- pattern: "\"org\\.apache\\.pinot\\.common\\.metrics\"<type=\"BrokerMetrics\", name=\"pinot\\.broker\\.(([^\\.]+)\\.)?([^\\.]*)\\.authorization\"><>(\\w+)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this follow java regex? If so [^\\.]
should be equivalent to [^.]
Can you share the documentation for the prometheus config? Do all fields take regex as input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just validated both metrics with [^\\.]
and [^.]
, you are right both are equivalent. Will make that update too.
Regarding the documentation for the prometheus config here is a link I referred.
According to the doc, only pattern
field takes a regex while capture groups from pattern can be used in labels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@zhtaoxiang 1 . Case 1 using |
I get the log for If my understanding is correct, isn't greedy matching slower? Because in most cases, the suffix will be much longer than the prefix, so greedy is slower. For example, if the pattern is |
@zhtaoxiang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @zhtaoxiang let me know if you have concern
Description
The
.
requires escaping throughout the pattern string if it is intended to represent a.
literal. The only reason its working right now is because its surrounded by specific patterns, so the match all.
regex is only matching actual.
character.More discussion around this issue (with an example where it breaks) here.
This PR tries to fix this by escaping all
.
literals.It also replaces
*?
with*
for custom metric rules as the surrounding pattern matching is well defined.labels
bugfix
refactor