# Max\_over\_time with sum

**URL:** <https://discuss.prometheus.io/t/max-over-time-with-sum/847>\
**Category:** PromQL\
**Created:** [March 15, 2022, 7:13pm UTC](https://discuss.prometheus.io/t/max-over-time-with-sum/847 "2022-03-15T19:13:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![reyes136](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@reyes136](https://discuss.prometheus.io/u/reyes136)\
**Post date:** [March 15, 2022, 7:13pm UTC](https://discuss.prometheus.io/t/max-over-time-with-sum/847/1 "2022-03-15T19:13:20Z")

</div>

I am using prometheus to manage multiple smart PDU’s with the snmp explorer, I need to track max power usage for different devices connected to these PDU’s. I have a list of PDU’s along with the outlets they are connected to. When I run my query i would like to sum/combine up the outlets used for a specific device then take the max power over a period of time. I can get the sum/combine working and the max\_over\_time on a entire pdu but when i try to use them together they fail. This is through http so its needed to all be in 1 request.

Working for sum/combine outlets:  
sum(pdu\_outlet\_sensor\_value{sensorType=“apparentPower”, instance=“[an2bpdub122m.pdu.com](http://an2bpdub122m.pdu.com)”,outletId=~“22|23|19”})

Trying to get max over time:  
max\_over\_time(sum(pdu\_outlet\_sensor\_value{sensorType=“apparentPower”, instance=“[an2bpdub122m.pdu.com](http://an2bpdub122m.pdu.com)”,outletId=~“22|23|19”})[2d])

ERROR:  
Error executing query: parse error at char 125: range specification must be preceded by a metric selector, but follows a \*promql.AggregateExpr instead

Any help would be appreciated.
