Skip to content

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

Closed

Description

@dan-petty

Problem

Three charts run defaults that the repo's values never turned off. Together they write about 140 MB a day to Loki's volume (plus Loki's own lines about the canary) and keep a cluster-wide watch on Secrets, and nobody reads any of it. Checked live on 2026-10-03.

Loki canary (chart loki 7.3.0). k8s/logging/loki-values.yaml has no lokiCanary key. The chart defaults are enabled: true, kind DaemonSet and push: true, and helm get values loki -a confirms them. logging/loki-canary runs 4/4.

  • Direct pushes: 4 streams {pod=loki-canary-*, service_name="unknown_service", stream="stdout"}, 295,742 lines and 29.6 MB in 24h.
  • Its stderr ("Querying loki for logs with query: ...") reaches Loki again through alloy-logs as job="logging/loki-canary": 84,493 lines and 16.9 MB in 24h. These are not duplicates of the entries; they are diagnostics.
  • Loki's own container logged 595,697 lines in 24h, and 321,376 of them mention canary.
  • Nothing reads the canary's metrics. There are no loki_canary_* series now or over 30 days, no ServiceMonitor or annotation selects it, and no rule references it. The logging policy admits monitoring on 3100 only, not on the canary's metrics port 3500.
  • feat(k8s): alert when pod logs stop reaching loki #890 already notes the canary "measures Loki, not the shipper".

Pyroscope runs at debug (chart pyroscope 2.3.1). helm show values grafana/pyroscope --version 2.3.1 sets pyroscope.extraArgs: {log.level: debug}. k8s/monitoring/pyroscope-values.yaml sets no log level, and the live container args include -log.level=debug.

Grafana's datasource sidecar watches for objects that don't exist (chart grafana 10.5.15). k8s/monitoring/grafana-values.yaml:115-116 sets sidecar.datasources.enabled: true, but all five datasources are provisioned inline (lines 44-83).

  • kubectl get cm,secret -A -l grafana_datasource returns nothing, and no file under k8s/, src/ or tests/ produces that label.
  • The grafana-sc-datasources container still runs METHOD=WATCH, RESOURCE=both, with the admin credentials mounted for its reload call. Its only output is "Loading incluster config..." twice a minute: 2,930 lines a day.
  • Because a sidecar is enabled and rbac.namespaced is unset, the chart renders a ClusterRole with get/watch/list on configmaps and secrets in every namespace. The live grafana-clusterrole grants exactly that.
  • The dashboards sidecar adds to it with searchNamespace: ALL and the chart default resource: both, although every dashboard ConfigMap lives in monitoring (k8s/monitoring/dashboards/kustomization.yaml).
  • Datasource provisioning doesn't depend on the sidecar. The inline file is mounted from the chart's own ConfigMap at /etc/grafana/provisioning/datasources/datasources.yaml.

Loki warns on every query that deletion is unavailable (found 2026-10-03, after #550). k8s/logging/loki-values.yaml keeps compactor.retention_enabled: true with delete_request_store: filesystem, which Loki 3 requires for retention, and closes the delete API with limits_config.deletion_mode: disabled (#550; the API would accept unauthenticated requests while auth_enabled is false). With that pair, Loki logs a deletion is not available for this tenant warning on every query, so each Grafana panel refresh adds lines to Loki's own log that say nothing new.

Loki admits the whole monitoring namespace. k8s/logging/networkpolicy.yaml:23-36 admits port 3100 from any pod in monitoring (a namespace-only peer) and only the collector's pods from otel (#1100). Loki runs with auth disabled, so any monitoring workload can push or query. Only Grafana (queries) and the k8s-monitoring Alloy collectors (alloy-logs pushes; alloy-metrics scrapes Loki once #1130 adds integrations.loki) need it. The narrowing was raised in #1100's review.

Acceptance criteria

  • k8s/logging/loki-values.yaml sets lokiCanary.enabled: false, with a comment that pipeline liveness comes from Alloy's series (feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131, feat(k8s): alert when pod logs stop reaching loki #890).
  • A Loki query no longer logs deletion is not available for this tenant, and the delete API stays closed: deletion_mode stays disabled, and retention still runs (compactor.retention_enabled: true). The PR names the Loki setting that stops the per-query lookup, citing the Loki 3.x documentation or source for the deployed chart's appVersion, and a values test pins it with deletion_mode.
  • Loki's ingress peer from monitoring in k8s/logging/networkpolicy.yaml names Grafana's pods and the k8s-monitoring Alloy collectors by their chart labels, in the combined namespace-and-pod peer form fix(security): Loki admits only the OpenTelemetry collector from otel, and persona exemplars always come from the review target's project #1100 uses for the otel collector, instead of the whole namespace. A policy test pins the peer set for port 3100, and fails if a namespace-only monitoring peer returns.
  • k8s/monitoring/pyroscope-values.yaml sets pyroscope.extraArgs.log.level: info. Helm deep-merges maps, so the chart's other extraArgs keys stay.
  • k8s/monitoring/grafana-values.yaml has the following:
    • sidecar.datasources.enabled: false;
    • sidecar.dashboards.searchNamespace: monitoring and sidecar.dashboards.resource: configmap;
    • rbac.namespaced: true, so the chart renders a Role in monitoring instead of a ClusterRole.
  • A test asserts, as one structural tuple:
    • lokiCanary.enabled;
    • Pyroscope's log.level;
    • the Grafana datasource sidecar flag;
    • the dashboard sidecar's searchNamespace and resource;
    • rbac.namespaced;
    • that every grafana_dashboard-labelled ConfigMap the kustomizations generate is in monitoring.
  • A test fails if any values file under k8s/ sets a log level of debug. It checks any log.level/logLevel/log_level key or -log.level=debug argument, in any values file the stack lifecycle installs. Verified by a mutation in review: setting Pyroscope's level back to debug must make it fail.
  • 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 and logging stacks are redeployed:
    • kubectl get ds -n logging lists no loki-canary;
    • kubectl get clusterrole grafana-clusterrole returns NotFound;
    • kubectl get role -n monitoring grafana -o jsonpath='{.rules}' grants configmaps;
    • Grafana still lists all five datasources and every provisioned dashboard, and the Loki datasource passes "Save & test";
    • alloy-logs logs no Loki write errors, and new log lines keep arriving;
    • over 1h, Loki's own log has no deletion is not available for this tenant line;
    • 24h later, sum by (job) (bytes_over_time({job=~"monitoring/pyroscope|logging/loki-canary|monitoring/grafana-sc-datasources"}[24h])) (Loki) is under 10 MB in total, and {service_name="unknown_service"} has no new lines;
    • also pending a person: kubectl delete clusterrolebinding grafana-clusterrolebinding and kubectl delete clusterrole grafana-clusterrole, if Helm leaves either behind (it should remove both).

Key questions

Strategic alignment

Activity

  1. added
    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). Four facts change or extend this item's criteria.

    1. No Loki setting stops the per-query cache-generation lookup, so the Loki criterion cannot be met as written.

    • On Loki 3.6.11 and on main, pkg/loki/modules.go adds the frontend's CacheGenNumberHeaderSetterMiddleware and the querier's CacheGenNumberContextSetterMiddleware whenever supportIndexDeleteRequest() and compactor.retention_enabled are both true. deletion_mode and the results-cache setting are never checked. pkg/compactor/deletion/grpc_request_handler.go GetCacheGenNumbers returns an error for a tenant without deletion, and generationnumber/gennumber_loader.go caches only successes, so every request asks again. Upstream Error messages seen when deletion_mode is disabled with runtime configuration grafana/loki#9855 (2023-07-04) is still open with no linked PR.
    • It is an error line as well as the warning: each query logs level=error caller=gennumber_loader.go:136 msg="error loading cache generation numbers" err="... deletion is not available for this tenant" plus level=warn method=/grpc.Compactor/GetCacheGenNumbers. On an ordinary day (2026-10-16) that was about 172k of each, 40% of Loki's own lines and 18.9% of all 1.82M lines ingested. 213,950 of about 214,200 Loki error lines in 24h come from that one caller, so a level=error search on Loki is useless today.
    • LokiRequestErrors (k8s/monitoring/prometheus-values.yaml:414) cannot see it: the gRPC route reports status_code="error", not 5xx; loki_request_duration_seconds_count{route="/grpc.Compactor/GetCacheGenNumbers",status_code="error"} runs at about 2/s.
    • Proposed replacement criterion: keep deletion_mode: disabled and retention, and drop exactly these two literal messages at the collector. k8s-monitoring 4.5.2's podLogsViaLoki feature exposes extraLogProcessingStages: a stage.match for {namespace="logging", container="loki"} with two stage.drop stages on the literal messages, a comment citing Error messages seen when deletion_mode is disabled with runtime configuration grafana/loki#9855, a test in tests/test_k8s.py, and removal once upstream fixes it. Verification: sum(count_over_time({namespace="logging",container="loki"} |= "deletion is not available for this tenant" [1h])) is 0. The gRPC error counter keeps rising, so it cannot be the check.
    • The canary criterion helps a lot: 2,904 of 2,937 frontend query-log lines in one hour (99%) were loki-canary queries, so disabling the canary removes about 90% of these lookups. Grafana's own queries still produce the lines, so the drop stage is still needed.

    2. Pyroscope also needs its usage-reporting opt-out, in the same extraArgs map.

    • Live monitoring/pyroscope (2.3.1) has no usage-stats flag, and pyroscope-config is {}. It is the only Grafana component without an opt-out: Loki (loki-values.yaml:9-10), Grafana (grafana-values.yaml:38-39), the k8s-monitoring Alloys (k8s-monitoring-values.yaml:271,284,297) and Tempo (tempo-values.yaml:8) all have one. That breaks AGENTS.md's mandatory opt-out rule, and docs/agent/tasks/task-943-...md:35 wrongly records "telemetry disabled".
    • With -architecture.storage=v2 the pod is a reporter follower (pkg/pyroscope/modules.go:602-610), so it waits forever for a seed file (pkg/usagestats/reporter.go:173-183) and sends nothing. It does log caller=reporter.go ... failed to read cluster seed file 1,882 times a day. An upgrade that changes leader selection would start reports through monitoring's open 443 egress.
    • Proposed: add usage-stats.enabled: "false" next to log.level: info. helm template of chart 2.3.1 renders -usage-stats.enabled=false with the chart's other args unchanged (flag registered at reporter.go:49). Pin it in tests/test_third_party_telemetry.py, correct task-943's line, and add a pending-a-person check that |= "caller=reporter.go" returns nothing over 1h.

    3. rbac.namespaced: true still leaves a Secret grant.

    • Chart grafana 10.5.15 templates/role.yaml hard-codes resources: ["configmaps", "secrets"] whenever any sidecar is enabled, whatever sidecar.*.resource says. With this item's values, helm template renders only a Role and RoleBinding, but Grafana keeps get/list/watch on Secrets in monitoring. Today that is grafana-admin; feat(k8s): alertmanager posts critical and warning alerts to mattermost's alerts channel, and a roadmap service repository whose rounds all fail for an hour alerts #1392 adds alertmanager-webhook there.
    • The token is mounted in the grafana server container too (the pod sets automount true), and Grafana serves anonymous Viewers through grafana-ingress. Live kubectl auth can-i confirms reads of Secrets in llm, cloudflared, devops and argocd today (names only checked).
    • Either accept and document the namespaced Secret grant, or use the chart's rbac.useExistingRole with a repo-owned configmaps-only Role. Re-check the template after the Grafana move to the grafana-community chart (filed separately), which may differ.

    4. Current canary figures. 3 pods (two Node objects were removed): 259,200 pushed lines and 76,988 stdout lines a day.

  3. added this to the v0.2.38 milestone on Oct 21, 2026
  4. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1781, merged into release/v0.2.38 as a3a345c.

    Closes #1133
    Part of #1128

    7 file(s) changed.

    How it was verified

    Check runs at 5235af0:

    • Fail-to-Pass Check: fail
    • 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
    • Changed-Test Independence: pass
    • Analyze (actions): pass
    • Rule Pack Tests: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Static Analysis: pass
    • Service Image: skipping
    • Dependency Freshness: skipping
    • DevContainer Image: skipping

    No task file.

  5. added
    type/bug
    and removed on Oct 30, 2026
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/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions