-
Notifications
You must be signed in to change notification settings - Fork 148
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
Improve path handling for Pushgateway #186
Comments
Hi @beorn7, I'm just running through our open issues and I wanted to ask your opinion on this one - particularly on handling special characters. I had a read through the Would it be a reasonable approach to do that all the time rather than trying to detect if a particular value needs encoding? My rough plan, assuming that's a sensible approach, would be:
Alternatively, if that's overkill (I can see how it would make debugging more of a pain when using simple examples), I'm thinking:
|
I guess you could just follow what I did in client_golang. Just always doing base64 is certainly a safe way to go, but I could see a loss of "quality of life" if you want to debug something, dump the URLs somehow, and then you have to decipher the base64 encoded parameters. As far as I can see, past me made an effort to only use base64 encoding if required: https://github.com/prometheus/client_golang/blob/master/prometheus/push/push.go#L309-L319 |
Yeah, that feels like the right way. Most of the time, the base64 encoding is just going to be a pain for debugging. I've just noticed while reading through the client_golang push code that it returns an error if the I'm not sure if this should also be applied for Unfortunately, perfoming that validation on @dmagliola I'm thinking we should hold off on releasing 3.0 so we can make this breaking change at the same time. #209 is currently on master. I'm happy to leave it there for now, on the assumption that I can get this done in the next few days and that we don't need to cut a release before then. If we did want to cut a release in a hurry for any reason, I propose we temporarily revert that PR. |
Just noted another thing we might need to change (pending a quick look at how the pushgateway handles it): in the Go library, they're using the I've created a draft PR at #220 for all this work. |
AFAIK it's not possible to encode a space as |
About the Yeah, there is a bit history behind the So the The special validation performed by client_golang has more to do with the grouping key in general (and the Any label that is part of the grouping key but also present in the metric to push will lead to an error in client_golang. That's just a safeguard against surprises. The PGW itself is fine with that case but will ruthlessly overwrite the labels present in the metric with the labels from the grouping key. So how to deal with the case in the client library is essentially a philosophical question. Personally, I'd say if someone is setting labels on the metric that are also present in the grouping key, they are doing something wrong, and probably without noticing. So I better let them know as early as possible. But if you want to put emphasis on making the code run, you could see that differently. So perhaps you would prefer to not validate but issue a warning somehow? |
Oh, TIL! I had no idea that was only for query params.
Ruby's URL/CGI escaping is a bit of a mess. This StackOverflow answer (which is way better than the accepted one on the question) gives a decent overview of how it ended up the way it is, but tl;dr we're gonna have to think it through and I'm gonna test it against a real pushgateway and see what happens.
I think that's more in line with how we do things in this library. I think the approach you mentioned works really well in a language like Go, where people can use I'm torn for the reasoning you mention though. We do raise an exception on observations with invalid label sets, and this doesn't feel too dissimilar to that in principle. @dmagliola Thoughts? |
Okay, after some local testing I can 100% confirm we're messing this up.
I tried sending a metric with different instance names to a local pushgateway. When using I'm going to play around and see if there's anything reasonable I can use from stdlib, particularly after the deprecation that led to #188. If not, we may have to pull |
Okay, that bug is fixed and I've merged #220 as an intermediate step in this work. The remaining items are:
|
I've just been working through this, and was looking at reusing Seeing as we're going to be shipping this as part of a major, breaking release, I'm going to add that validation to |
Guess a couple of quiet days over Christmas/New Years was just what I needed 😅 #234 is ready for review! As the changes to the push client are fairly drastic, I've done it as a series of small commits for ease of review. |
Currently, the code in
push.rb
only handles pushes to/metrics/job/%s
and'/metrics/job/%s/instance/%s
, and even those have some problems:/
, the push will fail.Please check out https://github.com/prometheus/pushgateway/blob/master/README.md to learn about arbitrary label pairs as grouping key and how to handle base64 encoding for
/
and empty values (the latter to be merged as prometheus/pushgateway#346 ).The text was updated successfully, but these errors were encountered: