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
'@ <timestamp>' modifier #8121
'@ <timestamp>' modifier #8121
Conversation
We have this prototype running at http://104.131.10.78:9090/graph if anyone wants to try it out. (Edit: this is running a prototype which can break in unknown ways. Not in sync with the PR.) |
Can we use scalar, instead of creating a new timestamp type? |
What do you mean by a scalar here? Does the timestamp |
Also, thanks for this and the demo!! I am asking for the timestamp/scalar because the first thing I tried is |
oooh wait the @ is not evaluated on every step, so my idea would not work. |
|
I think there are benefits in making the argument of For one, we probably want it to support an upcoming function However, I can see MTD-like queries where I want it to depend on the evaluation time, e.g. where you want to compare a value at time t to the value at the beginning of the month relative to t, i.e. something like To make the latter work nicely, we probably want an The final plug for a dynamic argument of |
To be clear: The above are just musings, not concrete suggestions what to implement in this PR. I think this is great as a demo. |
Yeah this prototype is just barebone stuff required for a PoC, other helpers like |
Note that this PR constitutes a breaking change to PromQL, and thus should not be merged. |
I see this as an incremental additional without breaking anything that exists right now. But anyway, should not be merged yes, just a PoC. |
I agree with @codesome that it is not breaking anything from what I can see |
It breaks the invariant that has existed for 5+ years that PromQL does not look into the future, and thus that no samples beyond the evaluation time of a query may be accessed. Users could be depending on this, thus it is a breaking change. |
I am definitely in favor of this modifier, love it! Thanks, @codesome for this prototype. What I like about this syntax is that is quite clear. Sure, there is some boilerplate but it's fully understandable and does what expected.
Hm @brian-brazil if that's the case isn't this as easy as returning an error when requested |
That's not the definition of a breaking change. |
First of all, no, it's not the case. This is not a breaking change. Everything that works before will continue to work in exactly the same way. Second, it is core to this feature that you @-request a timestamp from outside the queried range. For example, if you have a topk graph for the busiest CPUs over the last hour, and then you want to zoom in to look at a particular peak, you are now looking at a time interval in the past but still need to run the selecting query with the same fixed @-time. (This is BTW what most competing metrics systems get wrong with the "easy" task of displaying the top-5 busiest CPUs.) |
That would cover it, as long as it's not after the start time it can't break anyone downstream due to this.
I disagree. Anyone who depends on the not looking into the future invariant would be broken, and this is highly likely to affect at the least both explicit and implicit caching. We'd basically be asking for all users to audit all their uses of the API to see if this would impact on them, or any of their downstream users. Just because something isn't an explicitly enumerated behaviour doesn't mean that we can change it without causing breakage. |
Is anyone aware of any software relying this current behavior or is this a theoretical concern? A feature flag which is on for PromCorThanos and off by default would solve this if anyone is aware of anyone needing opt-in. |
Being theoretical is sufficient for it to be breaking. There's stuff I'd like to break that I'd expect to have zero real impact, but can't. In terms of concrete examples the most obvious would be Trickster, but I expect this would impact on large chunks of the userbase causing non-obvious breakage. I imagine there's tons of scripts out there running queries over "past" data and caching/storing it somewhere, presuming that the query result can't change as new data comes in.
I don't think this is what you meant to write, as upgrading does not equate to opting in to breaking changes. |
I feel we can discuss if it's breaking change or not in a different thread as this is not blocking this proposal as far as I get this, right? (: We expect the timestamp to be inside the queried range.
|
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
fee7181
to
4ddf152
Compare
I have updated this PR with the actual implementation and not a prototype anymore. I still have to fix 1-2 edge cases (the test cases failing are commented out), and have the add a flag. But otherwise, it is good for a review now. |
(Also, currently it only works with a timestamp, I will be adding support for |
Should be ready for another review. I have added the flag and docs. |
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.
I didn't do a deep re-review of the main logic, but on the other hand it didn't change.
dffd260
to
f4eebd7
Compare
I have fixed all the comments. I hope it is close to merge now :) |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
f4eebd7
to
7388423
Compare
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.
It's looking close. I'll want to a final full review of the core logic though, just in case I missed something or a bug slipped in during the final tweaks.
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
(In case it was missed, the PR was ready for review after the last commit) |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
d987d37
to
304793a
Compare
👍 |
// Offset is the offset used during the query execution | ||
// which is calculated using the original offset, at modifier time, | ||
// eval time, and subquery offsets in the AST tree. | ||
Offset time.Duration |
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.
Ooops, changing the meaning of an existing field without renaming / removing it caught me off guard and introduced a bug in PromLens where it now thinks all offsets are 0 (because Offset
is now always 0 after parsing). I know we don't have API stability guarantees, but in the future I would recommend in this type of situation to do it the other way around: keep the same semantics for the existing field and instead add another one for the new meaning (e.g. AdjustedOffset
or something like that).
This commit bumps the dependency on Prometheus to the commit from the v2.28.0 tag (https://github.com/prometheus/prometheus/releases/tag/v2.28.0). The reason for bumping this is to take advantage of the updates to the PromQL parser. Without this update, the prom-label-proxy cannot enforce labels on queries that use any new features, e.g. queries that include: * the last_over_time, sgn, clamp functions, added in prometheus/prometheus#8457; * the @ operator, added in prometheus/prometheus#8121; or * the group aggregation operator, added in prometheus/prometheus#7480. Currently, queries including these functions produce errors like: `parse error: unknown function with name "group"` Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit bumps the dependency on Prometheus to the commit from the v2.28.0 tag (https://github.com/prometheus/prometheus/releases/tag/v2.28.0). The reason for bumping this is to take advantage of the updates to the PromQL parser. Without this update, the prom-label-proxy cannot enforce labels on queries that use any new features, e.g. queries that include: * the last_over_time, sgn, clamp functions, added in prometheus/prometheus#8457; * the @ operator, added in prometheus/prometheus#8121; or * the group aggregation operator, added in prometheus/prometheus#7480. Currently, queries including these functions produce errors like: `parse error: unknown function with name "group"` In order to keep tests working, we need to pull in the latest commits from Alertmanager. This, however, does not satisfy `go mod` since v0.22.2 of Alertmanager, on which Prometheus depends, is not merged into main. As a result, we need a replace directive in the go.mod file for now. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit bumps the dependency on Prometheus to the commit from the v2.28.0 tag (https://github.com/prometheus/prometheus/releases/tag/v2.28.0). The reason for bumping this is to take advantage of the updates to the PromQL parser. Without this update, the prom-label-proxy cannot enforce labels on queries that use any new features, e.g. queries that include: * the last_over_time, sgn, clamp functions, added in prometheus/prometheus#8457; * the @ operator, added in prometheus/prometheus#8121; or * the group aggregation operator, added in prometheus/prometheus#7480. Currently, queries including these functions produce errors like: `parse error: unknown function with name "group"` In order to keep tests working, we need to pull in the latest commits from Alertmanager. This, however, does not satisfy `go mod` since v0.22.2 of Alertmanager, on which Prometheus depends, is not merged into main. As a result, we need a replace directive in the go.mod file for now. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit bumps the dependency on prom-label-proxy to include prometheus-community/prom-label-proxy#71. As described in that PR, the reason for bumping this is to take advantage of the updates to the PromQL parser. Without this update, the prom-label-proxy, and thus the Observatorium API cannot enforce labels on queries that use any new features, e.g. queries that include: * the last_over_time, sgn, clamp functions, added in prometheus/prometheus#8457; * the @ operator, added in prometheus/prometheus#8121; or * the group aggregation operator, added in prometheus/prometheus#7480. Currently, queries including these functions produce errors like: `parse error: unknown function with name "group"` Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
I'm pretty sure one or two blog posts were written showing how to use this feature, but I can't find them. |
This PR implements
@ <timestamp>
modifier as per this design doc.An example query:
which ranks based on last 1h rate and w.r.t. unix timestamp
1234
but actually plots the 1m rate.Closes #7903
This PR is to be followed up with an easier way to represent the start, end, range of a query in PromQL so that we could do
@ <end>
,metric[<range>]
easily.