Profiling
When troubleshooting backend issues with Grafana, then Go’s profiling tools can be turned on by starting the grafana-server
binary with the -profile flag:
grafana-server -profile
There is an optional -profile-port flag if you need to bind to another port other than the default 6060 port for net/http/pprof.
Pprof
net/http/pprof
is a library for profiling live Go applications and exposing the profiling data via HTTP. When profiling is turned on, then a new endpoint is exposed at port 6060.
An example - collecting a block profile:
go tool pprof --svg bin/grafana-server http://localhost:6060/debug/pprof/block > blocking.svg
Go Trace
A trace.out file is generated while running Grafana. This trace can be analyzed by running:
go tool trace trace.out
More reading on pprof and trace: