What is a subquery?
AdvancedConceptPromQL & Recording Rules
Answer
A subquery evaluates an instant query at a resolution over a range, producing a range vector you can feed to _over_time functions:
max_over_time(rate(http_requests_total[5m])[1h:1m])
This means "the highest 5-minute rate in the last hour, sampled every minute". Subqueries are expensive on large data; if you use one regularly, write the inner expression as a recording rule and apply max_over_time to that.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate