Skip to content
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

Actual timestamp() for max_over_time (and other agg functions) #5003

Open
ali-sattari opened this Issue Dec 15, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@ali-sattari
Copy link

ali-sattari commented Dec 15, 2018

Proposal

Use case. Why is this important?
Knowing when a min or max happened in defined window of time is useful. Imagine monitoring a gauge like metric over a week, you want to know the max value in that period (easy) and the time it happened (currently impossible using PromQL)

Something like:

max_over_time(shop_online_users{dimension="frontpage"}[1w])

Would give the value, but we don't know when the max point happened in 1w.

Suggestion
If only the timestamp() (or a new function) would return the actual timestamp of evaluated point in time, the problem would be solved:

timestamp(max_over_time(shop_concurrent_users{dimension="frontpage"}[1w]))

It returns now or actually same value as time() at the moment.

I can see the timestamp() can return the actual timestamp of a metric (only last value) when used without aggregate functions, as discussed in #1557

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Dec 15, 2018

That'd class as a breaking change, as the timestamp returned by a function is documented to be the eval time and returning other values would break graphing etc. It'd also be kkinda weird, why for max and not avg, quantile, or sum?

If you want this I'd suggest working from a graph, or using the API directly the fetch the data.

@ali-sattari

This comment has been minimized.

Copy link
Author

ali-sattari commented Dec 15, 2018

Yes, I figured, so if in any case it should be a new function.

I think any aggregate function that ultimately points to one record in timeline (min, max most notable) can be easily (in theory) be accompanied with the actual timestamp. The case for other aggregate functions such as avg or quantile gets complicated and perhaps not very useful.

I have the external solution (saving each new max or min in a separate metric) as an alternative in mind, but having this built in would be nice too.

This is rather the default mode in InfluxDB (although kind of comparing apples and oranges): https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#max

@roidelapluie

This comment has been minimized.

Copy link
Contributor

roidelapluie commented Dec 18, 2018

what if there are multiple timestamps ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.