Using pprof
On occasion, you may wish to have insight into how Prometheus is performing under the hood at a much lower level. For example, what specifically in the Prometheus code is causing my memory usage to be what it is? Or what is using so much CPU? Since Prometheus is written in Go, it can leverage Go’s native pprof system.
pprof
is a tool that came out of Google (https://github.com/google/pprof) that is used to produce, visualize, and analyze profiling data from applications. Prometheus exposes pprof
endpoints via HTTP under the /debug/pprof
path (for example, http://localhost:9090/debug/pprof):
Figure 7.2 – The /debug/pprof page on a Prometheus server
Although you can view all of these endpoints, such as /debug/pprof/heap
and /debug/pprof/goroutine
, in the browser, they are best used with the go
command-line program. Go has the built-in ability to retrieve and visualize pprof
data. For example, you can retrieve heap data like so...