Skip to content

feat(k8s): profiles come from k8s-monitoring's profiling feature for every workload, and the profiling dashboards list what is profiled #1134

Closed

Description

@dan-petty

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, image grafana/alloy:v1.12.2. The k8s-monitoring collectors run v1.19.2.
  • It has its own ClusterRole and ClusterRoleBinding (pyroscope-alloy) and ConfigMap alloy-config-pyroscope.
  • It discovers pods by profiles.grafana.com/* annotations. Only monitoring/pyroscope-0 and monitoring/pyroscope-alloy-0 carry them.
  • Through Grafana, service_name values 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 from charts/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.name annotation;
  • 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 $service is a custom variable hard-coded to monitoring/pyroscope, monitoring/alloy.
  • sre-service.json matches flamegraphs with service_name=~".*$service.*", where $service is kube_pod_info's created_by_name. That is a ReplicaSet hash name for every Deployment (for example grafana-6b7d85bbbb), so it never matches a Deployment's profiles.
  • k8s/README.md:183 says 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_name over 24h fails with loading object into memory segments/3/anonymous/01M3ZZZVGS5K1SDNNA7KHGR1JF/block.bin: read 0 bytes, expected 55344, and pyroscope-0 logs the same error with LabelValues 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.yaml sets alloy.enabled: false and drops the subchart's settings.
  • k8s/monitoring/k8s-monitoring-values.yaml gains the following:
  • pyroscope.json's service variable is a Pyroscope label_values(service_name) query. sre-service.json's flamegraph panels select by service_namespace="$namespace" and the workload's service_name, not by created_by_name.
  • prometheus-values.yaml gains PyroscopeQueryErrors (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:183 names 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-monitoring profiling".
  • Tests:
    • a test asserts, as one structural tuple, the Pyroscope alloy.enabled flag, 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 to collectors.alloy-profiles;
    • tests/test_third_party_telemetry.py covers the new collector;
    • a dashboard test asserts that neither profiling dashboard hard-codes a service_name list or reads created_by_name.
  • No test reaches the network. Each new test's call phase is under 1 s. A changelog.d/<n>.md fragment exists; CHANGELOG.md and docs/ROADMAP.md are untouched.
  • Pending a person, after the infra stack is redeployed:
    • kubectl get sts -n monitoring pyroscope-alloy returns NotFound;
    • kubectl get ds -n monitoring k8s-monitoring-alloy-profiles is ready on every node;
    • one hour later, Pyroscope's service_name values include the llm workloads (for example the gateway and Ollama tiers) and the monitoring stack.
  • Pending a person, the one-time cleanup, after the step above:
    kubectl get podlogs.monitoring.grafana.com -A
    kubectl delete crd podlogs.monitoring.grafana.com
    
    Expected: the first prints "No resources found" before the second runs.
  • 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 24h service_name label query succeeds, and PyroscopeQueryErrors stays inactive for 24h.

Key questions

Strategic alignment

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.

Activity

  1. added
    type/feature
    scope/k8s
    scope/telemetry
    priority/p2-medium
    on Oct 3, 2026
  2. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    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.

    • The goroutine flamegraph has never shown data. Panel 7, "Active Goroutines Flamegraph", uses profile type goroutine:goroutine:count:goroutines:count (k8s/monitoring/dashboards/pyroscope.json:164,167). Pyroscope stores goroutine:goroutine:count:goroutine:count (list_pyroscope_profile_types, 24h). Queried directly for service_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 every profileTypeId in pyroscope.json and sre-service.json is 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.
    • The torn-segment symptom no longer reproduces. The 24h service_name label query now succeeds, and pyroscope-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.
    • Unchanged: service_name over 24h is still exactly monitoring/alloy and monitoring/pyroscope. monitoring/pyroscope-alloy still runs Alloy v1.12.2 with resources: {}, against v1.19.2 in the k8s-monitoring Alloys.
  3. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1783, merged into release/v0.2.38 as 8dc020c.

    Closes #1134
    Part of #1128

    12 file(s) changed.

    How it was verified

    Check runs at fcb6481:

    • Fail-to-Pass Check: pending
    • Fail-to-Pass Self-Check: pass
    • Audit Defect PR Hardening: skipping
    • Prune PR DevContainer Images: pass
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • Static Analysis: pass
    • Changed-Test Independence: pass
    • Rule Pack Tests: pass
    • Analyze (actions): pass
    • Dependency Freshness: skipping
    • Service Image: skipping
    • DevContainer Image: skipping

    No task file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/k8sscope/telemetrytype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions