Skip to content

refactor(k8s): the monitoring stack runs on k8s-monitoring and chart features, with no duplicate collection, dead defaults or leftovers #1128

Closed

Description

@dan-petty

Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)

This section supersedes any text below that conflicts with it.

Decisions

Delivery
This parent has no PR. Each child is one PR, merged in this order. Each later PR rebases on the earlier ones that share its files.

  1. feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131 (S): open, Ready, no release. It adds the alloy and grafana integrations, enables Pyroscope's ServiceMonitor, adds the homelab-telemetry-pipeline rule group and adds the first chart allow-list fixture.
  2. feat(k8s): alert when pod logs stop reaching loki #890 (S): open, v0.2.37. It adds PodLogsNotShipped beside feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131's group and keeps no PodLogsDropped, which would duplicate feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131's AlloyLogEntriesDropped.
  3. fix(telemetry): devops-cli metrics reach prometheus in one hop, a late sample no longer drops a whole batch, and the collector runs only what its pipelines use #1132 (S): open, Ready, no release. It adds the out-of-order window, the one-hop remote write and the collector trim. It makes AlloyRemoteWriteSamplesFailed quiet.
  4. 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 (S): open, Ready, no release. It shares no file with fix(telemetry): devops-cli metrics reach prometheus in one hop, a late sample no longer drops a whole batch, and the collector runs only what its pipelines use #1132 or feat(k8s): alert when pod logs stop reaching loki #890, so it may merge before, after or alongside fix(telemetry): devops-cli metrics reach prometheus in one hop, a late sample no longer drops a whole batch, and the collector runs only what its pipelines use #1132. It must merge after feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131 because both edit k8s/monitoring/pyroscope-values.yaml.
  5. feat(k8s): profiles come from k8s-monitoring's profiling feature for every workload, and the profiling dashboards list what is profiled #1134 (M): open, no release. It comes after feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131 (its alert uses Pyroscope's ServiceMonitor) and after 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 (same pyroscope-values.yaml).
  6. feat(k8s): coredns metrics and a coredns dashboard #822 (S/M): open, no release. It adds the CoreDNS dashboard and alert on fix(k8s): the prometheus server scrapes only itself and the otel collector, and k8s-monitoring discovers every other target #1130's integrations/kubernetes/kube-dns job. It comes after feat(k8s): alert when pod logs stop reaching loki #890 because both add rules to k8s/monitoring/prometheus-values.yaml.
  7. fix(k8s): the kubernetes, node and ingress dashboards query only series something serves, checked against captured exporter families and the chart allow lists #1136 (M): open, no release. It comes after feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131, whose fixture format it reuses. If feat(k8s): coredns metrics and a coredns dashboard #822's dashboard lands first, fix(k8s): the kubernetes, node and ingress dashboards query only series something serves, checked against captured exporter families and the chart allow lists #1136's gate covers that dashboard too.
  8. Metrics for the rest of the platform #551 (M): open, v0.2.38. It adds the remaining platform scrapes to the integrations block and its egress rules.
  9. fix(k8s): deploy-stack warns about GPU nodes no Ollama tier accepts, k8s/README.md documents GPU placement, and the gateway's ServiceMonitor moves to the llm stack #1367 (S/M): open, no release. It goes last because it deletes extraObjects from k8s/monitoring/k8s-monitoring-values.yaml, after every other child that edits that file.

Acceptance criteria

Current references

Dependencies and order


Problem

An audit of the monitoring stack on 2026-10-03 read the repo at release/v0.2.25, the pulled charts, and the live cluster (read-only). The stack is half-migrated to the Grafana k8s-monitoring chart (#734, #737).

This parent issue groups the cleanup. Each child is one pull request with its own acceptance criteria.

Acceptance criteria

Children, merged in the order under "Strategic alignment":

On the live cluster, after the last deploy:

  • count by (job) (up) lists no kubernetes-api-servers, kubernetes-service-endpoints*, kubernetes-pods-slow, kubernetes-services or prometheus-pushgateway job.
  • prometheus_tsdb_head_series is below 30k (68.9k on 2026-10-03).
  • Node Exporter Full and the k8s views show data.
  • kubectl get ds -A shows no fluent-bit, loki-canary or k8s-monitoring-alloy-singleton DaemonSet, and kubectl get sts -n monitoring pyroscope-alloy returns NotFound.
  • Grafana's health check passes for every provisioned datasource.
  • kubectl get svc -n monitoring lists only chart-owned Services.
  • k8s/README.md's component-ownership table (fix(k8s): the prometheus server scrapes only itself and the otel collector, and k8s-monitoring discovers every other target #1130) matches the deployed stack.

Key questions

Strategic alignment

Order. Shared files decide the order. One PR per row, merged top to bottom; rows in the same step share no file and can run in parallel.

Step PRs Why here
1 #913; #1129; #1133; #548 Independent surfaces. #913 closes a live exposure. #1129 fixes the P1 regression. #548 and #913 both edit stack_lifecycle.py lists, so whichever merges second rebases. #1133 and #548 can merge in either order because of #548's amended criterion.
2 #1132 Must precede #1131's remote-write alert. Edits k8s-monitoring-values.yaml (receiver block) after #1129.
3 #1130 After #1129 (same file and the cluster-label convention). Creates the integrations block. Delivers #822's scrape.
4 #1131, then #890 Extends #1130's integrations block. Its alert is quiet only after #1132.
5 #1104, then #1134 #1134's destination uses the chart's pyroscope Service. #1104 has no order constraint with #1132 and may land earlier; it edits grafana-values.yaml and k8s-monitoring-values.yaml, so whichever of it and #1133/#1135 lands second rebases.
6 #1135 After #1132 (k8s/otel/values.yaml) and #1131 (integrations.tempo).
7 #1136; #795 #1136 needs #1129's fixture and #1130's scrape owners. #795 removes extraObjects from k8s-monitoring-values.yaml last.

#551 and #823 follow #1130 (they add scrapes to its integrations and egress rules). #822's dashboard follows #1130.

Files touched by several children, so each later PR rebases on the earlier ones:

No child edits CHANGELOG.md or docs/ROADMAP.md; each carries a changelog.d/ fragment (#933).

GitOps (#755).

PVC data.

Owner rules for every child: chart and library features before hand-written config; everything in git and applied by GitOps (#755); PVC data protected; no documentation-only PRs; prioritisation by the roadmap tooling (each child gives priority, value and effort; no milestones here).

Value. A smaller, cheaper and observable monitoring stack built on chart features. It cuts about 50k Prometheus series and about 300 MB a day of unread Loki writes (fluent-bit's duplicate copy, the canary and debug logs), and restores Node Exporter Full, profiling, traces and self-monitoring. Raised on 2026-10-03: further duplication, misconfiguration and missing integration with the Grafana k8s-monitoring Helm charts remain to be cleaned up.

Related, not children: #913 (perimeter; live drift recorded there), #755 (GitOps; chart baseline recorded there), #792 (sender-side ordering; target_info in scope), #408 (expected operator releases, leftover detection), #409 (Tempo ordering), #734/#737 (the migration this finishes), #953, #550, #549/#1094 (alerting the new rules route through), #1031 (moves the service-name constants).

No milestone; the roadmap tooling places the children.

Update 2026-10-08: refinement

Delivered: #548, #913 and #795; #795 handed the ServiceMonitor move (k8s/monitoring/k8s-monitoring-values.yaml:239-255) to #1367. #1104's pyroscope alias is gone, so step 5 no longer orders #1104 before #1134. #755 landed: checks run after the merge to main. #1129 adds no fixture; #1131 and #1136 own them.

Proposed design

Problem statement

The monitoring stack is half-migrated to the Grafana k8s-monitoring chart, leaving duplicated collection (two log shippers, two scrapers, two Alloy deployments, three Services in front of one Prometheus pod), values that do not take effect as written (node-exporter allow list narrowed by a flag meant to widen it, chart defaults running a Loki canary and debug logging nobody reads), unused chart integrations (nothing scrapes Alloy, Grafana or Pyroscope; traces unreadable and lost on restart), and live-cluster drift from git (pre-#953 perimeter, kube-prometheus-stack leftovers). This parent issue groups the cleanup into ordered child pull requests that restore the stack to chart-native shapes, cut roughly 50k Prometheus series and 300 MB/day of unread Loki writes, and bring the live cluster back in line with git.

Acceptance criteria

Key questions

Fit

Needs splitting into 15 items:

  1. fix(k8s): k8s-monitoring collectors run in the chart's preset shapes, and node-exporter keeps the series the node dashboards read #1129: k8s-monitoring collectors run in the chart's preset shapes, and node-exporter keeps the series the node dashboards read (P1, S)
  2. fix(k8s): the prometheus server scrapes only itself and the otel collector, and k8s-monitoring discovers every other target #1130: the Prometheus server scrapes only itself and the otel collector; k8s-monitoring discovers every other target, with one scrape owner and one egress rule per scrape port (P1, M)
  3. feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131: Alloy, Grafana and Pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts (P2, S)
  4. fix(telemetry): devops-cli metrics reach prometheus in one hop, a late sample no longer drops a whole batch, and the collector runs only what its pipelines use #1132: devops-cli metrics reach Prometheus in one hop, a late sample no longer drops a batch, and the collector runs only what its pipelines use (P2, S)
  5. 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: chart defaults stop writing logs and watches nobody reads (Loki canary and per-query delete warnings, Pyroscope debug, Grafana datasource sidecar), and Loki admits only Grafana and Alloy from monitoring (P2, S)
  6. feat(k8s): profiles come from k8s-monitoring's profiling feature for every workload, and the profiling dashboards list what is profiled #1134: profiles come from k8s-monitoring's profiling feature for every workload (P2, M)
  7. feat(telemetry): traces are stored in tempo on a volume, and grafana and devops-cli read them, linked to logs and profiles #1135: traces are stored in Tempo on a volume, and Grafana and devops-cli read them (P2, L)
  8. fix(k8s): the kubernetes, node and ingress dashboards query only series something serves, checked against captured exporter families and the chart allow lists #1136: the Kubernetes, node and ingress dashboards query only served series, under the capture gate (P3, M)
  9. fix(k8s): pod logs reach loki once and labelled, with alloy as the only shipper (remove fluent-bit) #548: pod logs reach Loki once (single shipper; amended with the 2026-10-03 numbers and the canary criterion)
  10. 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: every alias Service in k8s/monitoring/service-aliases.yaml is removed (absorbs chore(k8s): drop the kube-prometheus-stack service aliases #818, widened to the prometheus alias and the live kube-prometheus-stack leftovers)
  11. fix(k8s): deploy-stack applies the llm gateway policy and narrows its egress #795: the gateway policy is applied, and the gateway's ServiceMonitor moves to the llm stack (amended)
  12. feat(k8s): coredns metrics and a coredns dashboard #822: the CoreDNS dashboard and alerts; fix(k8s): the prometheus server scrapes only itself and the otel collector, and k8s-monitoring discovers every other target #1130 delivers the scrape (amended)
  13. feat(k8s): alert when pod logs stop reaching loki #890: an alert when pod logs stop reaching Loki, on feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131's Alloy series (amended)
  14. Metrics for the rest of the platform #551: the remaining platform scrapes (ArgoCD, Valkey, the registry) through k8s-monitoring features (amended)
  15. feat(k8s): qdrant metrics with an authenticated scrape, and its dashboard row restored #823: Qdrant metrics through an authenticated scrape, under the same scrape rule

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/refactor
    scope/k8s
    scope/telemetry
    priority/p1-high
    on Oct 3, 2026
  2. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Proposal needs splitting into 15 items at 69c99cf (see proposed design in issue body).

  3. modified the milestone: v0.2.36 on Oct 11, 2026
  4. dan-petty commented on Oct 14, 2026

    @dan-petty
    OwnerAuthor

    Moved to the backlog: it was New, not Ready, when v0.2.36 started. (devops roadmap reprioritize)

  5. added this to the v0.2.37 milestone on Oct 17, 2026
  6. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Readiness check for v0.2.37, against release/v0.2.36 at 22d8748. Line numbers are at that commit.

    Status: partly done. This is a parent tracking issue with no slice of its own.

    Children

    Still in the files

    • The integrations at k8s/monitoring/k8s-monitoring-values.yaml:177 lack alloy, grafana and pyroscope.
    • pyroscope-values.yaml enables its bundled Alloy.
    • Grafana's datasource sidecar is on (grafana-values.yaml:122).
    • The Loki canary is not disabled.
    • prometheusMetricsReceiver is on (k8s-monitoring-values.yaml:150).
    • The OTel collector writes through Alloy (k8s/otel/values.yaml:87-88), with the debug exporter in every pipeline.

    Partly fixed by #792: the sender side only, plus native histograms at prometheus-values.yaml:16. #1132's out_of_order_time_window, its one-hop remote write and its collector trim are still missing.

    References that moved

    • The ServiceMonitor at k8s-monitoring-values.yaml:239-255 is now at :307-323.
    • service-aliases.yaml is gone.
    • The Scrape Ownership table is at k8s/README.md:151.

    The live checks need cluster access.

    Questions for the owner

    Order

    1. Ready now: 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 (S) and fix(telemetry): devops-cli metrics reach prometheus in one hop, a late sample no longer drops a whole batch, and the collector runs only what its pipelines use #1132 (S).
    2. Then feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131 (S), followed by feat(k8s): alert when pod logs stop reaching loki #890 (S).
    3. Then feat(k8s): profiles come from k8s-monitoring's profiling feature for every workload, and the profiling dashboards list what is profiled #1134 (M), fix(k8s): the kubernetes, node and ingress dashboards query only series something serves, checked against captured exporter families and the chart allow lists #1136 (M), feat(k8s): coredns metrics and a coredns dashboard #822 (S/M), Metrics for the rest of the platform #551 (M) and fix(k8s): deploy-stack warns about GPU nodes no Ollama tier accepts, k8s/README.md documents GPU placement, and the gateway's ServiceMonitor moves to the llm stack #1367 (S/M).
  7. removed this from the v0.2.37 milestone on Oct 17, 2026
  8. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Moved to the backlog: it was New, not Ready, when v0.2.37 started. (devops roadmap reprioritize)

  9. added this to the v0.2.38 milestone on Oct 20, 2026
  10. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1794, merged into release/v0.2.38 as 1651384.

    Closes #1128

    17 file(s) changed.

    How it was verified

    Check runs at 0150849:

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

    Acceptance Criteria of docs/agent/tasks/task-1128-monitoring-stack-k8s-monitoring-and-chart-features.md:

    • k8s/monitoring/k8s-monitoring-values.yaml integrations gains the alloy (k8s-monitoring) and grafana (grafana) instances.
    • k8s/monitoring/pyroscope-values.yaml sets serviceMonitor.enabled: true, and test_prometheus_operator_crds_install_before_every_service_monitor includes ("infra", "pyroscope").
    • k8s/monitoring/prometheus-values.yaml gains the homelab-telemetry-pipeline rule group with AlloyRemoteWriteSamplesFailed, AlloyLogEntriesDropped, and PodLogsNotShipped.
    • tests/test_k8s_monitoring_alerting.py asserts, as structural tuples, the pipeline drop rules and scrape settings (feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131) and PodLogsNotShipped's name, expression, for duration, and severity (feat(k8s): alert when pod logs stop reaching loki #890).
    • tests/test_k8s_monitoring_alerting.py asserts that every Alloy metric name the homelab-telemetry-pipeline rules use is in tests/fixtures/k8s_monitoring/integrations/alloy.yaml and that the fixture header matches the k8s-monitoring chart version pin in src/devops_cli/commands/k8s/stack_lifecycle.py.
    • tests/test_k8s_monitoring_integration.py _scrape_owners handles list-valued labelSelectors and chart-default app.kubernetes.io/name selectors.
    • k8s/README.md documents the Alloy, Grafana, and Pyroscope scrapes and the new alerts.
    • k8s/logging/loki-values.yaml sets lokiCanary.enabled: false and documents the Loki 3.6.11 GetCacheGenNumbers behavior with deletion_mode: disabled and compactor.retention_enabled: true.
    • k8s/logging/networkpolicy.yaml narrows the monitoring ingress peer on TCP 3100 to Grafana and the three k8s-monitoring Alloy collectors, and tests/test_k8s_network_policies.py pins the peer set and rejects a namespace-only monitoring peer.
    • k8s/monitoring/pyroscope-values.yaml sets pyroscope.extraArgs.log.level: info and k8s/monitoring/grafana-values.yaml disables the datasource sidecar and scopes the dashboard sidecar and RBAC to monitoring ConfigMaps, verified by structural tuple and debug-log-level tests in tests/test_k8s_monitoring_integration.py.
    • k8s/monitoring/pyroscope-values.yaml disables the bundled Alloy subchart (alloy.enabled: false) and k8s/monitoring/k8s-monitoring-values.yaml configures destinations.localPyroscope, profiling (ebpf.targetingScheme: all and pprof), and collectors.alloy-profiles.
    • k8s/monitoring/dashboards/pyroscope.json and k8s/monitoring/dashboards/sre-service.json query service_name from Pyroscope without hard-coded service lists or created_by_name, and k8s/monitoring/prometheus-values.yaml adds PyroscopeQueryErrors.
    • k8s/monitoring/dashboards/coredns.json and tests/fixtures/metrics/coredns.yaml add the CoreDNS dashboard over captured coredns_* series (job="integrations/kubernetes/kube-dns"), verified by tests/test_stack_dashboards.py and tests/test_k8s_monitoring_dashboards.py.
    • ingress-tunnel.json, k8s-views-global.json, k8s-views-namespaces.json, k8s-views-nodes.json, and otel-collector.json queries match exported series and labels, verified against tests/fixtures/metrics/ and tests/fixtures/k8s_monitoring/cluster_metrics/ in tests/test_stack_dashboards.py (fix(k8s): the kubernetes, node and ingress dashboards query only series something serves, checked against captured exporter families and the chart allow lists #1136).
    • Argo CD (ServiceMonitors for controller, server, repoServer, and redis-exporter), llm/valkey (redis-exporter sidecar via annotationAutodiscovery), and registry (annotationAutodiscovery on port 5001) have exactly one scrape owner and one monitoring egress rule per port, and homelab-services alerts on Argo CD sync/health, tunnel HA connections, and Valkey cache errors (Metrics for the rest of the platform #551).
    • k8s/llm/gateway/servicemonitor.yaml moves the llm-gateway ServiceMonitor out of k8s/monitoring/k8s-monitoring-values.yaml (extraObjects) into k8s/llm and _POST_HELM_BY_STACK["llm"], applied after Helm releases and deleted before Helm uninstalls, with SkipDryRunOnMissingResource=true on k8s/argocd/apps/llm.yaml (fix(k8s): deploy-stack warns about GPU nodes no Ollama tier accepts, k8s/README.md documents GPU placement, and the gateway's ServiceMonitor moves to the llm stack #1367).
    • The GPU placement node-label warning and README GPU placement section remain tracked on fix(k8s): deploy-stack warns about GPU nodes no Ollama tier accepts, k8s/README.md documents GPU placement, and the gateway's ServiceMonitor moves to the llm stack #1367.
    • Pending a person: after the deploy (Argo CD's sync of the merged revision, or devops k8s deploy-stack on a cluster without Argo CD):
      • count by (job) (up) lists no kubernetes-api-servers, kubernetes-service-endpoints*, kubernetes-pods-slow, kubernetes-services or prometheus-pushgateway job, and prometheus_tsdb_head_series is below 30k;
      • count by (job) (up{job=~"integrations/alloy|integrations/grafana|.*pyroscope.*"}) shows 3 Alloy targets, 1 Grafana and 1 Pyroscope, and sum by (pod) (loki_write_sent_entries_total) returns one row per alloy-logs pod and alloy-singleton;
      • AlloyRemoteWriteSamplesFailed, PodLogsNotShipped, and PyroscopeQueryErrors stay inactive on a healthy cluster;
      • kubectl get ds -n logging lists no loki-canary, kubectl get clusterrole grafana-clusterrole returns NotFound, and kubectl get role -n monitoring grafana -o jsonpath='{.rules}' grants configmaps;
      • kubectl get sts -n monitoring pyroscope-alloy returns NotFound, kubectl get ds -n monitoring k8s-monitoring-alloy-profiles is ready on every node, kubectl get podlogs.monitoring.grafana.com -A prints "No resources found" before kubectl delete crd podlogs.monitoring.grafana.com, and any zero-length block.bin torn segments in Pyroscope's segments/ directory are backed up and moved aside with Pyroscope scaled to 0;
      • up{job="llm-gateway"} == 1 after deploy-stack --stack llm alone on a cluster running the infra stack, and helm get manifest k8s-monitoring -n monitoring | grep -c ServiceMonitor prints 0.
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/p1-highscope/k8sscope/telemetrytype/refactor

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions