How Do I Find a Weighted Average?

Because Observe can support many different use cases with many types of data, it can sometimes be difficult to select the correct OPAL tool. Here’s a way to calculate the weighted average of aggregated data.

rollup options(buckets:100), cpu_usage:metric("cpu_usage_total", rollup:"rate", type:"cumulativeCounter")
make_col weight:case(
  contains(cpu_type, "expensive"), 2.0,
  contains(cpu_type, "normal"), 1.0)
aggregate avg_cpu_usage:avg(cpu_usage * weight), group_by(cluster_uid, node_name)