RousselTMLEARNING

Observability

Analyzing profiles in Grafana: flame graphs, comparisons and diagnostics

A method for analyzing profiles in Grafana: Profiles Drilldown, flame graph and top table, comparing two periods (diff), memory and lock profiles, real diagnostic cases.

1. A four-step method #

From symptom to line of code.

Method #

Available in: ✓ OSS ✓ Enterprise ✓ Cloud Pyroscope open source and Grafana Cloud Profiles

  1. Start from a symptom: high CPU on a dashboard, degraded p99 latency, OOMKilled.
  2. Choose the right profile type: CPU for consumption, wall clock for latency, inuse_space for a leak, alloc_space for GC pressure, mutex/block for contention.
  3. Narrow the scope by labels (service_name, pod, endpoint) and by time range.
  4. Read the top table sorted by self time, then the flame graph to understand where the calls come from.

2. Comparing two periods #

The diff feature.

Before / after #

The Comparison view (diff flame graph) overlays two selections: the baseline and the comparison. Functions in red consume more, those in green less. It is the ideal tool to:

  • compare version N and N+1 (version label);
  • compare a CPU spike with a normal period;
  • compare two regions or two instance types.
Good practice: Always add a version label (commit or tag) to your profiles: every deployment becomes comparable in one click.

3. Real cases #

What you actually find.

Frequent examples #

SymptomProfileTypical finding
High CPUprocess_cpuRegular expression compiled on every call, reflection-based JSON serialization
Very active GCalloc_spaceString concatenations in a loop, slices not pre-allocated
Memory growing endlesslyinuse_spaceCache without eviction, blocked goroutines holding on to objects
High latency, low CPUwall, block, mutexGlobal lock, connection pool too small
Cloud costprocess_cpu aggregated across the fleetA logging library costs 15% of total CPU
// Avant : compilée à chaque appel (visible dans le flame graph : regexp.Compile)
func isValid(s string) bool { return regexp.MustCompile(`^[A-Z]{3}-\d+$`).MatchString(s) }

// Après : compilée une fois
var ref = regexp.MustCompile(`^[A-Z]{3}-\d+$`)
func isValid(s string) bool { return ref.MatchString(s) }

Profiles in dashboards #

Grafana's Flame graph panel can be placed in a dashboard next to the service's CPU metrics. You can also plot a series derived from profiles (for example the CPU of a given function) to track the effect of an optimization over time.

Related articles

Continuous profiling with Grafana Pyroscope: why and how

The fourth signal of observability: what continuous profiling is, profile types (CPU, memory, locks), reading…

Grafana Pyroscope architecture and deployment

Pyroscope components (distributor, ingester, querier, store-gateway, compactor), object storage, monolithic a…

Instrumenting applications for Pyroscope: SDKs, Alloy and eBPF

Send profiles to Pyroscope from Go, Java, Python and Node.js with the SDKs, collect pprof endpoints with Allo…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!