Prometheus PromQL max_over_time for multiple metrics with different names

In Prometheus PromQL I can do the following:

{name=~“oracledb_ohlprod_conn_count_.”}

And I get the following:

ELEMENT VALUE
oracledb_ohlprod_conn_count_1{host=“10.223.16.30”,instance=“10.223.16.30:9163”,job=“oracledb_exporter”} 1234
oracledb_ohlprod_conn_count_2{host=“10.223.16.30”,instance=“10.223.16.30:9163”,job=“oracledb_exporter”} 1272

I can also do the following:

max({name=~“oracledb_ohlprod_conn_count_.”})

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

ELEMENT VALUE
{} 1257

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

max_over_time({name=~“oracledb_ohlprod_conn_count_.”})[3h]

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):

max_over_time({name=~“oracledb_ohlprod_conn_count_.”}[3h])

I ge the error:

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

BOTTOM LINE:

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