title: PromQL - how combine "sum_over_time" with "by"
body: <p>I'm trying to write a query that will return the following information:</p>
  <p>for metric m1 (of type counter)  - return the sum of values, grouped by (p1,p2) in a sliding window of 1h.</p>
  <p>I think the base should be something like:</p>
  <pre><code>sum_over_time(m1[1h])
  </code></pre>
  <p>but this cannot be grouped by (p1,p2)</p>
  <p>One way to do the grouping is by</p>
  <pre><code>sum(sum_over_time(m1[1h])) by (p1, p2) 
  </code></pre>
  <p>but i'm not sure if adding the external sum here, just in order to group, is the way to go.</p>
  <p>Another possibility it to do:</p>
  <pre><code>topk(100, sum_over_time(m1[1h])) by (p1, p2) 
  </code></pre>
  <p>but in this case the grouping doesn't seem to happen right, as the results contain a lot of rows with the same (p1,p2) and different in some other labels (p3,p4)</p>
  <p>what is the correct way to sum a metric, in a sliding window, by some lables?</p>