-
Run the agent with the
PROFILE_PORT
variable set to e.g. 6060.- If you are executing the agent from the Openshift NetObserv Operator, you can do it by
adding the following section to your
ebpf
spec:
apiVersion: flows.netobserv.io/v1alpha1 kind: FlowCollector metadata: name: cluster spec: agent: ebpf: debug: env: PROFILE_PORT: "6060"
- If you are executing the agent from the Openshift NetObserv Operator, you can do it by
adding the following section to your
-
If you are running OpenShift/Kubernetes, port-forward the pod that you want to profile.
oc -n netobserv-privileged port-forward <netobserv-ebpf-agent pod name> 6060
-
Download the required profiles:
curl -o <profile> http://localhost:6060/debug/pprof/<profile>
Where
<profile>
can be:
allocs
: A sampling of all past memory allocationsblock
: Stack traces that led to blocking on synchronization primitivescmdline
: The command line invocation of the current programgoroutine
: Stack traces of all current goroutinesheap
: A sampling of memory allocations of live objects.- You can specify the
gc
GET parameter to run GC before taking the heap sample.
- You can specify the
mutex
: Stack traces of holders of contended mutexesprofile
: CPU profile.- You can specify the
duration
in the seconds GET parameter.
- You can specify the
threadcreate
: Stack traces that led to the creation of new OS threadstrace
: A trace of execution of the current program.- You can specify the
duration
in the seconds GET parameter.
- You can specify the
Example:
curl "http://localhost:6060/debug/pprof/trace?seconds=20" -o trace20s
curl "http://localhost:6060/debug/pprof/profile?duration=20" -o profile20s
curl "http://localhost:6060/debug/pprof/heap?gc" -o heap
curl "http://localhost:6060/debug/pprof/allocs" -o allocs
curl "http://localhost:6060/debug/pprof/goroutine" -o goroutine
- Use
go tool pprof
to dig into the profiles (go tool trace
for thetrace
profile)