Prometheus PromQL max_over_time for multiple metrics with different names

In Prometheus PromQL I can do the following:


And I get the following:

oracledb_ohlprod_conn_count_1{host=“”,instance=“”,job=“oracledb_exporter”} 1234
oracledb_ohlprod_conn_count_2{host=“”,instance=“”,job=“oracledb_exporter”} 1272

I can also do the following:


And I get the following (slightly different data as some time has went by):

{} 1257

But if I do something like the following (range outside parens):


I get the error:

Error executing query: invalid parameter ‘query’: 1:59: parse error: ranges only allowed for vector selectors

And if I do the following (range inside parens):


I ge the error:

Error executing query: vector cannot contain metrics with the same labelset


I am trying to get the max over time of different named metrics.

Not differently qualified metrics of same name, but max over time of multiple metrics with different names.

Something like “get the max over time for given range for each metric, then get the max of those results”.

I am not sure if this is possible in PromQL, or if it is possible and I have not found the right documentation or understood the right documentation.

All help is appreciated! Thank you!

Ok I finally found the solution here: kubernetes - Calculate Max over time on sum function in Prometheus - Stack Overflow

For me the implementation was:
max_over_time(max({ name =~“oracledb_. ? maxqcount [^r]. ”})[$__range:1m])

Basically above says:
Use name lookup to get list of matching label names
Take max across those names
Use PromQL subquery to then take max of those for the currently selected dashboard range at resolution interval of 1 minute