Reputation: 658
My situation is this: I am using Prometheus with Grafana, and with a graph, want to sum() my metrics in groups based on what their value of the label "mylabel" is. I have a metric, mymetric, with label mylabel.
mymetric{name: thing1, mylabel: a}
mymetric{name: thing2, mylabel: b}
mymetric{name: thing3, mylabel: a}
I want all of my metrics with mylabel value "a" to be sum() together into one line on the graph, while metrics with mylabel value "b" are sum() together onto the same graph. The problem is, I don't know what values "a" and "b" will be. I just want things that happen to have the same value to be sum together.
Is this possible?
Upvotes: 6
Views: 10690
Reputation: 34122
In general you don't need to know the label values for aggregation, so:
sum by (mylabel)(mymetric)
Upvotes: 8