-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
API client Series() call can't handle minTime/maxTime set by prometheus #614
Comments
Fixes prometheus#614 Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
That sounds like a bug on the Prometheus end, however I also recall that Go has some limits in terms of what it can handle time wise. |
@brian-brazil Yea, I could go either way on this TBH (client or server issue). If we were to tackle this server-side then IMO we'd want to pass some other time down the stack (presumably min/max that can be represented in what the API requires) -- right now the time we set is not expressible in the format the API requires. |
@krasi-georgiev assigning to you as the API expert. Perhaps you have an opinion/idea? |
Something else that occurs to me is that if this is something that could also affect other languages, then we should probably fix it on the server. |
+1 on fixing server side |
What fix do we want server side? Should I just change the min/max time to
the min/max that can be represented as the timestamp type we use?
…On Wed, Jul 3, 2019, 5:22 AM Krasi Georgiev ***@***.***> wrote:
+1 on fixing server side
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#614?email_source=notifications&email_token=AAMLPHMLHAGW5TD3X5JUI73P5SKY5A5CNFSM4H45Z6Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZEIQ7Q#issuecomment-508070014>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMLPHMWF46DHX6YJVZGJILP5SKY5ANCNFSM4H45Z6YQ>
.
|
Hmm, looking a bit more this looks like a Go bug. The parser can only handle 4 digit years. golang/go#20555 is related, but different. |
Well, as a workaround until it supports more than 4 digit year dates, we could change the min/max to:
Which buys us 7980 years to sort that out :) Alternatively we could implement parsing for the current min/max times |
@brian-brazil friendly bump on #614 (comment) :) |
I'm not sure what the best way to deal with this is to be honest, as I don't think a Go fix is coming soon. |
Our options for a server-side fix are (1) set min/max time to something the time package can parse or (2) implement the time parsing ourselves (there's already a Either approach is fine IMO we just have to pick one :) |
The latter is probably better, I can imagine changing the guard value in future could cause issues. But I don't feel strongly on this. |
I had another idea, instead of implementing all the parsing I just added special-case checks for min/max time (prometheus/prometheus@32c3b7c -- part of prometheus/prometheus#5734) This way we can delay implementing the actual time parsing (hopefully upstream sorts that out?) but still be able to unmarshal our own time range :) |
That's a good idea. |
Related to prometheus/client_golang#614 Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
Related to prometheus/client_golang#614 Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
Prometheus has issues parsing RFC3339Nano timestamps if the year has more than 4 digits, in addition it is the second-pass parse attempt. Since this is a client library and the interface is a `time.Time` it makes sense that we pick the clearest simplest format-- so I propose we use the `model.Time` representation of time in our communications to prometheus. This (1) removes the issues with timezones in those queries going downstream and (2) completely works around this prometheus#614 issue as the parsing mechanism in prometheus can handle those times in this format. Related to prometheus#614
In addition to the server fix, IMO we should do #617 as a (1) simplification and (2) more complete workaround on the client side. |
Prometheus has issues parsing RFC3339Nano timestamps if the year has more than 4 digits, in addition it is the second-pass parse attempt. Since this is a client library and the interface is a `time.Time` it makes sense that we pick the clearest simplest format-- so I propose we use the `model.Time` representation of time in our communications to prometheus. This (1) removes the issues with timezones in those queries going downstream and (2) completely works around this prometheus#614 issue as the parsing mechanism in prometheus can handle those times in this format. Related to prometheus#614 Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
Hm, why not leave as is so that we will know when the server is not behaving as it should? |
…5734) * Add tests to ensure we can marshal and unmarshal our min/max times Related to prometheus/client_golang#614 Instead of implementing all the time parsing, we can special-case handle these 2 times. This means if times in this format show up that time.Parse can't handle they will still error, but we can marshal/parse our own min/max time Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
The fix we put in on the server side is a hack really because of the shortcomings of stdlib time parse. The prom API already supports 2 timestamp formats, so it makes sense to change this client to the one that "just works" |
Prometheus has issues parsing RFC3339Nano timestamps if the year has more than 4 digits, in addition it is the second-pass parse attempt. Since this is a client library and the interface is a `time.Time` it makes sense that we pick the clearest simplest format-- so I propose we use the `model.Time` representation of time in our communications to prometheus. This (1) removes the issues with timezones in those queries going downstream and (2) completely works around this prometheus#614 issue as the parsing mechanism in prometheus can handle those times in this format. Related to prometheus#614 Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
Prometheus has issues parsing RFC3339Nano timestamps if the year has more than 4 digits, in addition it is the second-pass parse attempt. Since this is a client library and the interface is a `time.Time` it makes sense that we pick the clearest simplest format-- so I propose we use the `model.Time` representation of time in our communications to prometheus. This (1) removes the issues with timezones in those queries going downstream and (2) completely works around this prometheus#614 issue as the parsing mechanism in prometheus can handle those times in this format. Related to prometheus#614 Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
This is a bit of a convoluted error so I'll do my best to explain.
If an API call to
/series
is made without a start/end time prometheus sets minTime/maxTime as the value (https://github.com/prometheus/prometheus/blob/master/web/api/v1/api.go#L462). If I then turn around and use this time with the API client (to presumably send the same request) I get an error:This is because the times used for minTime/maxTime can't be formatted to an RFC3339Nano timestamp. So for my use case in promxy I get a call from grafana (in this example) with no start/end time -- so prometheus sets the time to these min/max times but then I cannot pass that time down to another prometheus to fetch the data, as its not a valid timestamp.
Go playground showing the behavior: https://play.golang.org/p/hM_DWyv0JMK
So I'm not sure what we want to do exactly to handle this. Locally I have copied the min/max times into the client package and are optionally not setting the start/end times if they match. I'm not a major fan of the copy/paste of vars, but unfortunately those times are also private in the prometheus api/v1 package (https://github.com/prometheus/prometheus/blob/master/web/api/v1/api.go#L441). Alternatively we could make it so the client doesn't set the start/end if start/end are
time.IsZero()
which would allow the client/caller to pick when they don't send the timestamp (instead of us transparently doing it in the client).The text was updated successfully, but these errors were encountered: