Imagine I have metrics like this:
sample_metric{type="some-type1-1234"} 2
sample_metric{type="some-type1-5678"} 1
sample_metric{type="some-type2-9876"} 4
sample_metric{type="some-type2-4321"} 3
Now I would like to sum the metric values based on types that follow the same pattern. So, for the above example the desired result would be to have 2 sums:
type1: 3
type2: 7
This question is somewhat similar to this one, however in my case I don't know the groups in advance. I just know the pattern that they follow. Is there a way to achieve this with one query using regex?