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

Making durations and number literals the same #9138

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

darshanime
Copy link
Contributor

@darshanime darshanime commented Jul 30, 2021

@darshanime darshanime changed the title Allow number literals for matrix selector Making durations and number literals the same Jul 30, 2021
@darshanime darshanime marked this pull request as ready for review July 31, 2021 16:06
@roidelapluie
Copy link
Member

Thank you. I expect that Beorn will want to look at this one, but you can expect some delays due to the summer period.

@LeviHarrison
Copy link
Member

According to your design doc, the following should work: rate(prometheus_http_requests_total[0.25]), but instead I get this error: Error executing query: 1:37: parse error: strconv.Atoi: parsing "0.25": invalid syntax. Otherwise seems good!

@juliusv
Copy link
Member

juliusv commented Aug 12, 2021

I tried predict_linear(foo[5h], 1h), but I get:

parse error: trailing commas not allowed in function call args

I also left some comments on the design doc on questions I had.

@juliusv
Copy link
Member

juliusv commented Aug 12, 2021

One thing I'm interested in is how this will affect the printing of PromQL expressions once they have been parsed.

It would be sad if the input was:

predict_linear(foo[1h], 4h)

...and we could only serialize it out again as:

predict_linear(foo[1h], 14400)

Not sure if this is the plan already, but would it make sense to store the original tokens in the parsed AST somehow so that we can render them out again in a way that makes most sense to the user?

@beorn7
Copy link
Member

beorn7 commented Aug 16, 2021

One thing I'm interested in is how this will affect the printing of PromQL expressions once they have been parsed.
[…]

That's a good point, but perhaps we can solve that later, once the main functionality is implemented.

I think the comments above( #9138 (comment) , #9138 (comment) ) are real issues that need to be fixed.

@darshanime darshanime force-pushed the duration_number_duality branch 3 times, most recently from 00f908b to 20fdee0 Compare August 30, 2021 18:12
@darshanime
Copy link
Contributor Author

thank you, will address 👍
marking as draft to avoid notifications in the meantime...

@darshanime darshanime marked this pull request as draft August 30, 2021 18:16
@darshanime darshanime force-pushed the duration_number_duality branch 3 times, most recently from 3094b01 to 89c8d21 Compare October 20, 2021 16:31
@darshanime darshanime marked this pull request as ready for review October 20, 2021 17:13
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might come from my ignorance of parser internals, but wouldn't it be easier to just get rid of the DURATION type altogether and replace it with NUMBER everywhere? And then parse each number as a duration.

@stale stale bot added the stale label Dec 22, 2021
@valyala
Copy link

valyala commented Jul 15, 2022

FYI, VictoriaMetrics supports using durations instead of numeric values and vice versa in MetricsQL. See, for example, how does predict_linear(sum(rate(vm_http_requests_total[300])) offset 3600, 3h) work in VictoriaMetrics playground. It would be great if Prometheus could support this too.

@beorn7
Copy link
Member

beorn7 commented Aug 22, 2023

We discussed this during our bug scrub. I think my point above is still valid and hasn't been addressed. @darshanime are you still up to working on this?

This general topic comes up quite often, so we should finish this up one way or another.

Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: beorn7 <beorn@grafana.com>
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and adjusted the version (as this will land in 2.54, not 2.53).

@beorn7 beorn7 merged commit 58963f7 into prometheus:main Jul 10, 2024
25 checks passed
@bboreham
Copy link
Member

/prombench main

@prombot
Copy link
Contributor

prombot commented Jul 11, 2024

⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️

Compared versions: PR-9138 and main

After successful deployment, the benchmarking results can be viewed at:

Other Commands:
To stop benchmark: /prombench cancel
To restart benchmark: /prombench restart main

@bboreham
Copy link
Member

/prombench cancel

@prombot
Copy link
Contributor

prombot commented Jul 11, 2024

Benchmark cancel is in progress.

@bboreham
Copy link
Member

Sorry, it's pointless comparing against main when the PR has been merged.

@prombot
Copy link
Contributor

prombot commented Jul 14, 2024

Benchmark tests are running for 3 days! If this is intended ignore this message otherwise you can cancel it by commenting: /prombench cancel

@bboreham
Copy link
Member

/prombench cancel

@prombot
Copy link
Contributor

prombot commented Jul 14, 2024

Benchmark cancel is in progress.

jan--f added a commit to jan--f/prometheus that referenced this pull request Jul 18, 2024
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>

Conflicts:
	VERSION
          pick 3.0.0
	promql/promqltest/testdata/histograms.test
          pick changes from c39776c,
          but adjust 5m range selectors to 10m to account for
          prometheus#13904.
Fixes:
        promql/promqltest/testdata/functions.test
	promql/promqltest/testdata/staleness.test
          Tests added in prometheus#9138
          need to be adjusted to account for
          prometheus#13904.
bboreham added a commit to bboreham/prometheus that referenced this pull request Jul 24, 2024
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

10 participants