You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Prometheus从Belkin Wemo毫瓦样本生成累计千瓦时曲线图?

Hey there! Let's figure out how to get that cumulative kWh graph working for your Belkin Wemo and Prometheus. I get where you're coming from—your current query gives accurate hourly kWh values, but you need those to stack up into a running total over time.

First, let's break down why your initial sum() attempt didn't work: the standard sum() in Prometheus aggregates across label dimensions (like multiple devices) at a single point in time, not across the timeline itself. To build a running total, you need a function that accumulates values over time: running_sum().

Here's the adjusted query you need:

running_sum(
  sum_over_time(current_power[1h]) / 1000 / 1000 / count_over_time(current_power[1h])
)

Or, since your original calculation is equivalent to taking the average power over the hour and converting it to kWh, you can simplify it to:

running_sum(
  avg_over_time(current_power[1h]) / 1000000
)

A quick breakdown of what this does:

  • avg_over_time(current_power[1h]) calculates the average power (in mW) over each 1-hour window—this matches the logic you already confirmed is accurate.
  • Dividing by 1000000 converts mW to kW, and since we're evaluating 1-hour windows, this directly gives us kWh per hour.
  • running_sum() takes each hourly kWh value and adds it to the total from all previous windows, creating a smooth, monotonically increasing curve that tracks your total energy use since data collection started.

Don't forget to keep your min_step=1h setting—this ensures Prometheus evaluates the query in 1-hour increments, matching the window you're using for power averaging.

If you have multiple Wemo devices (and your current_power metric has labels for each), wrap the current_power in a sum() first to get total power across all devices before calculating the average:

running_sum(
  avg_over_time(sum(current_power)[1h]) / 1000000
)

This should give you exactly the cumulative kWh graph you're looking for—each point on the curve will be the total energy consumed from the start of data collection up to that hour, matching the sum of your hourly table values.

内容的提问来源于stack exchange,提问作者smbaker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:21:06