Files
nexus/knowledgebase/csd-wiki/ICSD/How-to-generate-flame-graph-for-specific-container_686074188.md
2026-04-18 17:09:43 +08:00

49 lines
1.6 KiB
Markdown

# How-to-generate-flame-graph-for-specific-container_686074188
## Introduction
This guide presents the steps to generate flamegraph for specific container
## When to use this guide?
Usually when the issue happens on specific deployment and basic monitoring metrics cannot help on the troubleshooting.
## Deployment
1. Deploy [Krew](https://github.com/kubernetes-sigs/krew) on bastion
1. Make sure that `git` is installed.
2. Run this command to download and install `krew`:
```
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
```
3. Add the `$HOME/.krew/bin` directory to your PATH environment variable. To do this, update your `.bashrc` or `.zshrc` file and append the following line:
```
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
```
4. Run `kubectl krew` to check the installation.
2. Install kubectl-prof
```
kubectl krew index add kubectl-prof https://github.com/josepdcs/kubectl-prof
kubectl krew search kubectl-prof
kubectl krew install kubectl-prof/prof
kubectl prof --help
```
## Take the flame graph
1. Find the pod / container with issue
2. Take the flame graph
```
kubectl prof itom-xruntime-platform-offline-xxxxxxxxxx-xxxxx -n itsma-xxxxx -t 1m -l java -o flamegraph --local-path=/temp itom-xruntime-platform
```
3. Analyze on the flamegraph
Reference