Here’s the corrected version of your text:
I’m a newbie in PromQL, so I might be missing some principles of PromQL queries. I’ve checked the documentation, but I need a more detailed explanation. For example, I have a counter, let’s name it some_counter
with many labels. I want two things:
- Aggregate metrics by one label, let’s call it
tag
; thesum by
operator suits well here. - See counts only for a selected time range; there, the
increase
anddelta
operators are used.
So, I tried to write something like this (Grafana Labs):
increase(sum by(tag) (some_counter) [$__range])
, but it doesn’t compile.
After some research, I figured out about subqueries, and got this:
increase(sum by(tag) (some_counter) [$__range:$__interval])
It works, but I’m not sure it’s what I was looking for. Subqueries seem to be a more powerful feature than I need here. The Subqueries PR motivation states, “Sometimes, there are cases when you want to spot a problem using a rate with lower resolution/range (e.g., 5m) while aggregating this data for a higher range,” and it’s not what I want. I don’t need to spot problem rates with lower resolution; I just want to sum metrics by label and then calculate changes over a selected time range at least just subtract the first value. Also, as I understand, subqueries are expensive and should be used carefully, and the graphs look strange; I see some floating values, unusual curvatures, so it seems there are some complex calculations under the hood.
I don’t believe that subqueries are suitable for my simple task. Maybe there are other ways here? Perhaps I don’t understand the concept of PromQL.