Comments (8)
For a bit of background (shouldve added that earlier):
We run a shared prometheus platform used by many teams. I want to do some analysis of those rules to help teams with some company specifics (architecture). As its an all python team I'm using this library as pyo3 makes it really easy.
So changing the regex isn't an option, they come from end users and are valid for prometheus itself.
I guess its hard to fix as its a regex implementation difference between go and rust. If there was a 'less strict' regex flag I would be ok with that. What do you think?
I'm open to implementing something for it
from promql-parser.
Maybe it's because the difference between regex implementation of Rust and Go. I will try to fix it.
Thanks for your report, and any PR is welcome.
from promql-parser.
hi @yuanbohan, wow faster answer than I expected <3. I was taking a quick look as well:
For reproducing:
use regex::Regex;
fn main() {
let re = r#"/v[1-9]/.*/{gid}/{uid}"#;
Regex::new(&re).unwrap();
}
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
/v[1-9]/.*/{gid}/{uid}
^
error: repetition quantifier expects a valid decimal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)', src/main.rs:20:21
Which makes sense, not sure what a good fix is here
from promql-parser.
![promql](https://private-user-images.githubusercontent.com/474727/279000310-39870a08-77c0-4d26-9e3b-e5be8f9ed365.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg5NjY5NTgsIm5iZiI6MTcxODk2NjY1OCwicGF0aCI6Ii80NzQ3MjcvMjc5MDAwMzEwLTM5ODcwYTA4LTc3YzAtNGQyNi05ZTNiLWU1YmU4ZjllZDM2NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjIxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyMVQxMDQ0MThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZWI4MmE2ZjgzZTc4Njc0M2Y2Mjg1ODkzMWE0MWFjNDg1ODI1ZDA4NGIzMDk4MGVlNmVjMmFlNjdjZmYyMDIwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.FuvLo6lZs9M5y9RynvDn96nadcB7r91JwxuaiMUNL-s)
Just to verify that prometheus itself handles the regex as expected (or not expected), it shows series
from promql-parser.
Maybe you can try other symbols in your uri, like <
, _
?
Or just escape the curly brackets using \
in your regex?
from promql-parser.
let re = r#"/v[1-9]/.*/\{gid\}/\{uid\}"#;
let cap = Regex::new(&re).unwrap().captures("/v1/foo/{gid}/{uid}");
println!("{cap:?}");
==== output
Some(Captures({0: 0..19/"/v1/foo/{gid}/{uid}"}))
Is this what you want? @fbs
from promql-parser.
I guess its hard to fix as its a regex implementation difference between go and rust. If there was a 'less strict' regex flag I would be ok with that. What do you think?
From the regex lib's doc I can't find any configuration to control such behavior 🙁
Not a regex expert, but what do you think of adding some "preprocess" to modify the input regex rule like @yuanbohan said:
Maybe you can try other symbols in your uri, like
<
,_
? Or just escape the curly brackets using\
in your regex?
I'm not sure if this is viable...
from promql-parser.
I indeed ended up adding some preprocessing in #76. Its not the nicest implementation but it seems to work. Bit worried about some other edge cases I've missed.
from promql-parser.
Related Issues (16)
- Lexer: keep the lines in lex
- Lex: context with &str and lifetime, instead of String and clone HOT 1
- Parser: rules conflict
- support native histograms
- Support pretty print of Expr HOT 2
- Add Extension Expr type for customizing the parsed AST
- Add Expr Visitor trait HOT 1
- Cannot parse `time() > 1` HOT 1
- Merge AggModifier and VectorMatchModifier
- walk_expr does not traverse function arguments HOT 4
- Multiple `__name__` matchers not permitted HOT 3
- check regex compatibility
- use nom HOT 3
- feat: Support Filtering by multiple or filters HOT 7
- Error: better error mechanism is needed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from promql-parser.