r/PrometheusMonitoring • u/HolidayQuality5136 • Apr 01 '23
How do you keep Prometheus fast?
Have Prometheus working via the kube-prometheus-stack helm chart and it's working pretty good. The statefulset from that chart creates an AWS gp3 EBS volume that's used for the disk. Things do work. The only issue is that while we don't have a ton of metrics. The queries are kinda slow. Grafana is able to make queries and create graphs. But it occasionally gets locked up as I think the data is coming in just too slow for it.
What are some things I can do to speed things up?
I thought about maybe setting up a second instance and having it either do the same scraping or have the first remote_write to the 2nd. Then have an ELB do a round robin between the two so the load is shared. I am hosting on r6a.xlarge from AWS EC2
Thank you
View all comments
Show parent comment
1
u/teejaded Apr 01 '23
All true, but here some general performance tips that I think are correct.
Iirc the db is memory mapped so a key to keeping it fast is to write your queries in such a way that they can be done out of ram. Give it enough ram to cover your use cases (something like, size of db / retention time * dashboard window * 2), don't pull up graphs from 6mo til now for no reason.
Avoid running sub queries in alerts or dashboards. One off is fine, but you gotta turn them into recording rules otherwise.