How is it possible to know the total number of unique metrics in Prometheus - Stack Overflow
Prometheus metric to count the total number of requests routed to the instances of a deployment/configuration
Counter reset after target restart
Prometheus not showing up count of 5xx errors
What are Prometheus metrics?
How do Counter metrics work in Prometheus?
What is the format of Prometheus metrics?
Hi,
I'm trying to troubleshoot Prometheus high memory usage. While I can view my top x metrics with high cardinality, to get an idea, I want to know the total number of metrics that prometheus is currently storing in tsdb. Is there a query that can be useful here?
Thanks In advance.
prometheus_tsdb_head_series
Just because I always forget and have to Google this, and this question is at the top. As per this answer there will likely be a variance between prometheus_tsdb_head_series & count({__name__=~".+"}) because of variations in what they consider "active", but unless you have a large variability in metric count, I'd recommend prometheus_tsdb_head_series because if you have a lot of metrics, it's a lot faster to query.
How about count({__name__=~".+"})?
It does return number of time series in the database. I compared with amount of metrics currently exposed by each target by manual scrapping, and it matches it +/- 10%. I guess the difference is due to some targets that I had in the past and now they are offline.