How to get rate of individual metrics in prometheus/grafana while using a wildcard?

Viewed 121

I've got a number of counters in my service that are incrementing everytime I receive a price update. Using prometheus/client_golang, I create these counters like this:

priceCounter := promauto.NewCounter(prometheus.CounterOpts{
        Name: fmt.Sprintf("my_thing_%s_%s_price_update_total", exchange, stock),
    })

In grafana, I filter for {__name__=~"my_thing.*price_update_total"} - this works, and I can see my counters going up, but I'd like to apply a rate() to it, ie: rate({__name__=~"my_thing.*price_update_total"}[1m])

But when doing this, I get the error "vector cannot contain metrics with the same labelset". I found this quote rate() keeps all labels except __name__, but it drops __name__ to avoid any confusion., but I'm not sure how to proceed.

I tried applying rate() to these metrics without wildcards, and it works, but I have far too many to do my hand. Does this mean I need to add a namespace and a subsystem for every different price that I want metrics on? I'm quite new to prometheus and still trying to figure my way around things, and have hit a wall.

0 Answers
Related