Repository navigation
Description
Problem
Profiling runs on a second, older Alloy that profiles only Pyroscope and itself. k8s/monitoring/pyroscope-values.yaml:38-44 sets alloy.enabled: true, so the grafana/pyroscope 2.3.1 chart runs its bundled Alloy subchart. Checked live on 2026-10-03.
- The bundled Alloy is statefulset
pyroscope-alloy, imagegrafana/alloy:v1.12.2. The k8s-monitoring collectors run v1.19.2. - It has its own ClusterRole and ClusterRoleBinding (
pyroscope-alloy) and ConfigMapalloy-config-pyroscope. - It discovers pods by
profiles.grafana.com/*annotations. Onlymonitoring/pyroscope-0andmonitoring/pyroscope-alloy-0carry them. - Through Grafana,
service_namevalues for the last hour are[monitoring/alloy, monitoring/pyroscope]. No LLM, gateway or CLI workload is profiled. - The subchart also created CRD
podlogs.monitoring.grafana.com, at 2026-10-02T08:11:33Z, the same second as the pyroscope release's revision 1. It comes fromcharts/alloy/charts/crds, and no PodLogs object exists.
k8s-monitoring 4.5.2 ships what this replaces. profiling has ebpf, java and pprof sub-features, all off, and its eBPF targetingScheme defaults to annotation; all profiles every pod. It also has a pyroscope destination type (destinations/pyroscope-values.yaml), and the repo uses none of these. eBPF sets service_name from, in order:
- the pod's
resource.opentelemetry.io/service.nameannotation; app.kubernetes.io/instance;app.kubernetes.io/name;- the workload name.
It also sets service_namespace. The monitoring namespace enforces PSA privileged, so a privileged eBPF DaemonSet is admitted.
The dashboards can't show anything else either.
k8s/monitoring/dashboards/pyroscope.json's$serviceis a custom variable hard-coded tomonitoring/pyroscope, monitoring/alloy.sre-service.jsonmatches flamegraphs withservice_name=~".*$service.*", where$serviceiskube_pod_info'screated_by_name. That is a ReplicaSet hash name for every Deployment (for examplegrafana-6b7d85bbbb), so it never matches a Deployment's profiles.k8s/README.md:183says profiles are "collected by the Alloy profiling agent".
Torn segments break long-range queries, and health checks don't notice.
list_pyroscope_label_values service_nameover 24h fails withloading object into memory segments/3/anonymous/01M3ZZZVGS5K1SDNNA7KHGR1JF/block.bin: read 0 bytes, expected 55344, andpyroscope-0logs the same error withLabelValues status=500.- These are zero-length segment objects on the local-path volume, left by a restart about 15h earlier. Grafana's datasource health check still reports OK.
Acceptance criteria
-
k8s/monitoring/pyroscope-values.yamlsetsalloy.enabled: falseand drops the subchart's settings. -
k8s/monitoring/k8s-monitoring-values.yamlgains the following:destinations.localPyroscope: {type: pyroscope, url: http://pyroscope.monitoring.svc.cluster.local:4040}, the chart's own Service once fix(k8s): the pyroscope Service alias collides with the pyroscope Helm release's own Service, so a fresh deploy-stack can't install Pyroscope #1104 removes the alias;profiling: {enabled: true, collector: alloy-profiles, ebpf: {enabled: true, targetingScheme: all}, pprof: {enabled: true}};collectors.alloy-profileswithpresets: [daemonset, privileged],alloy.enableReporting: falseand resource requests and limits like the other collectors.
-
pyroscope.json's service variable is a Pyroscopelabel_values(service_name)query.sre-service.json's flamegraph panels select byservice_namespace="$namespace"and the workload'sservice_name, not bycreated_by_name. -
prometheus-values.yamlgainsPyroscopeQueryErrors(warning): Pyroscope's 5xx request rate over 15m is above 0 for 15m. It is built on the series feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131's ServiceMonitor brings in, with the metric and label names read from that scrape. -
k8s/README.md:183names the k8s-monitoring profiling feature. fix(k8s): the prometheus server scrapes only itself and the otel collector, and k8s-monitoring discovers every other target #1130's ownership table says "Pyroscope server: separate release; collection: k8s-monitoringprofiling". - Tests:
- a test asserts, as one structural tuple, the Pyroscope
alloy.enabledflag, the destination type and URL host, the profiling sub-features and targeting scheme, and the collector's presets; - the existing assertion
tests/test_k8s.py:1475(pyro_values["alloy"]["alloy"]["enableReporting"]) moves tocollectors.alloy-profiles; tests/test_third_party_telemetry.pycovers the new collector;- a dashboard test asserts that neither profiling dashboard hard-codes a
service_namelist or readscreated_by_name.
- a test asserts, as one structural tuple, the Pyroscope
- No test reaches the network. Each new test's call phase is under 1 s. A
changelog.d/<n>.mdfragment exists; CHANGELOG.md and docs/ROADMAP.md are untouched. - Pending a person, after the infra stack is redeployed:
kubectl get sts -n monitoring pyroscope-alloyreturns NotFound;kubectl get ds -n monitoring k8s-monitoring-alloy-profilesis ready on every node;- one hour later, Pyroscope's
service_namevalues include thellmworkloads (for example the gateway and Ollama tiers) and the monitoring stack.
- Pending a person, the one-time cleanup, after the step above:
Expected: the first prints "No resources found" before the second runs.
kubectl get podlogs.monitoring.grafana.com -A kubectl delete crd podlogs.monitoring.grafana.com - Pending a person, segment recovery, using the procedure the key question below settles. The PVC is kept, and its
segments/tree is copied to a backup location before anything is moved. Expected: a 24hservice_namelabel query succeeds, andPyroscopeQueryErrorsstays inactive for 24h.
Key questions
-
eBPF for all pods, or pprof annotations per service? Proposed: both, as the chart offers.
- eBPF with
targetingScheme: allgives CPU profiles for every process with no workload change, which covers Ollama, LiteLLM and the gateway. - pprof adds memory, goroutine and mutex profiles for the Go services that opt in by annotation (Pyroscope, Alloy and Grafana already serve pprof).
- Opt-outs use the chart's
excludeNamespaces(for examplekube-system) if the overhead shows up on the node dashboards.
- eBPF with
-
Can the nodes run the eBPF profiler? Proposed: verify in the PR. Every node needs a kernel with BTF (
/sys/kernel/btf/vmlinuxpresent) before merge. A node without it gets anodeSelectorexclusion on the collector rather than a hand-built profiler. -
Does
privilegedwiden the attack surface? Proposed: it is the chart's documented requirement for eBPF. It is confined to one DaemonSet inmonitoring, which already enforcesprivilegedforalloy-logs. The pod gets no Secret access beyond its service account. -
How are the torn segments recovered? Proposed: the PR first looks for a supported repair path in Pyroscope v2's documentation and issue tracker (metastore or compaction repair). If there is none:
- scale Pyroscope to 0;
- back up the
segments/tree; - move aside only the zero-length
block.binobjects named in the errors; - scale back.
The objects are already unreadable, so the loss is bounded to them, and the PVC is kept.
-
Why not wait for fix(k8s): the pyroscope Service alias collides with the pyroscope Helm release's own Service, so a fresh deploy-stack can't install Pyroscope #1104 before pointing the destination at
pyroscope.monitoring.svc? Proposed: the name doesn't change. fix(k8s): the pyroscope Service alias collides with the pyroscope Helm release's own Service, so a fresh deploy-stack can't install Pyroscope #1104 removes the alias manifest and keeps the chart's Service of the same name. Merge order is fix(k8s): the pyroscope Service alias collides with the pyroscope Helm release's own Service, so a fresh deploy-stack can't install Pyroscope #1104 first, so the destination never targets an alias.
Strategic alignment
- P2 feature: profiling today covers only the profiler itself, and long-range queries fail.
- Value: medium-high (CPU profiles for every LLM and gateway workload; one Alloy version instead of two). Effort: M (two values files, two dashboards, one rule, tests, plus one-time cleanup).
- Library-first: k8s-monitoring's
profilingfeature andpyroscopedestination replace a second Alloy deployment. - Related: feat(k8s): integrate grafana pyroscope to the monitoring stack #943/feat(k8s): expose pyroscope ui endpoints, port-forwarding and grafana dashboards #977 (origin), fix(k8s): the pyroscope Service alias collides with the pyroscope Helm release's own Service, so a fresh deploy-stack can't install Pyroscope #1104 (chart Service; merge first), Disable third-party telemetry and phone-home across k8s stack and devcontainer #803 (reporting off), fix(k8s): the prometheus server scrapes only itself and the otel collector, and k8s-monitoring discovers every other target #1130 (ownership table), feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131 (Pyroscope ServiceMonitor, which the alert uses), fix(k8s): chart defaults stop writing logs and watches nobody reads (loki canary and per-query delete warnings, pyroscope debug logging, grafana's datasource sidecar), and loki admits only grafana and alloy from monitoring #1133 (Pyroscope log level; same file, different keys).
Update 2026-10-08: refinement
#1281 deleted the pyroscope alias, so this no longer waits on #1104. Lines: k8s/README.md:175, tests/test_k8s.py:1552. #1357 moves sre-service.json panels 19 and 20; whichever merges second rebases.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 18, 2026
Update 2026-10-18 from a read-only cluster audit (main 3dd7fa6). This item already edits
pyroscope.json; here is one more fix for it, plus a re-check of the torn-segment problem.goroutine:goroutine:count:goroutines:count(k8s/monitoring/dashboards/pyroscope.json:164,167). Pyroscope storesgoroutine:goroutine:count:goroutine:count(list_pyroscope_profile_types, 24h). Queried directly forservice_name="monitoring/pyroscope"over 1h, the stored id returns about 8,000 goroutines and the dashboard's id returns an empty series. Proposed criterion: fix the id, and add a file-only test that everyprofileTypeIdinpyroscope.jsonandsre-service.jsonis in a captured profile-type list, kept as a fixture with the Pyroscope version (2.3.1). Mutation: restoring the typo must fail the test.service_namelabel query now succeeds, andpyroscope-0's last-24h logs have 0 "read 0 bytes" and 0 "status=500" lines. Re-check before running the pending-a-person segment recovery; it may no longer be needed.service_nameover 24h is still exactlymonitoring/alloyandmonitoring/pyroscope.monitoring/pyroscope-alloystill runs Alloy v1.12.2 withresources: {}, against v1.19.2 in the k8s-monitoring Alloys.dan-petty commentedon Oct 21, 2026
What changed
#1783, merged into
release/v0.2.38as 8dc020c.12 file(s) changed.
How it was verified
Check runs at fcb6481:
No task file.