Skip to content

fix(monitoring): alloy writes only the cluster label to loki, as it does to prometheus #1657

Closed

Description

@dan-petty

Friction

Every log stream k8s-monitoring writes to Loki carries both cluster and k8s_cluster_name with the same value, while Prometheus series carry only cluster. The two stores label the cluster differently, so a selector built from Loki's label browser on k8s_cluster_name matches nothing in Prometheus. #1129 fixed the Prometheus destination and its PR (#1500) named the Loki destination as an owner follow-up that was never filed.

Evidence

Live, read-only, 2026-10-18:

  • Loki label names include both cluster and k8s_cluster_name; k8s_cluster_name has one value, equal to cluster. {cluster=~".+", k8s_cluster_name=""} and the reverse each return 0 streams over 24h (85 streams in 24h carry both). It adds no streams or cardinality.
  • Prometheus label names have cluster and no k8s_cluster_name.
  • ConfigMaps monitoring/k8s-monitoring-alloy-logs and -alloy-singleton render loki.write "localloki" with external_labels = {"cluster" = ..., "k8s_cluster_name" = ...}; -alloy-metrics renders prometheus.remote_write "localprometheus" with only "cluster".

Repo:

  • k8s/monitoring/k8s-monitoring-values.yaml:13-15 sets clusterLabels: [cluster] on localPrometheus only, with a comment that the chart default would also write k8s_cluster_name; localLoki (:16-18) inherits the k8s-monitoring 4.5.2 default [cluster, k8s.cluster.name] (chart destinations/loki-values.yaml:74, written as external labels by _destination_loki.tpl:165-169).
  • tests/test_k8s_monitoring_integration.py:271-276 (test_alloy_writes_the_cluster_name_once) pins only the Prometheus destination.
  • docs/agent/tasks/task-1129-k8s-monitoring-presets-and-node-exporter-series.md:17 scopes fix(k8s): k8s-monitoring collectors run in the chart's preset shapes, and node-exporter keeps the series the node dashboards read #1129 to the Prometheus destination. Nothing in k8s/, src/ or tests/ reads k8s_cluster_name.
  • An offline helm template of chart 4.5.2 with destinations.localLoki.clusterLabels: [cluster] differs from today's render in exactly two lines: the k8s_cluster_name external label leaves loki.write "localloki" in alloy-logs and alloy-singleton.

Remedy

  1. Test first: extend test_alloy_writes_the_cluster_name_once to assert, as one tuple, that localPrometheus and localLoki both have clusterLabels == ["cluster"].
  2. k8s/monitoring/k8s-monitoring-values.yaml:16-18: add clusterLabels: [cluster] to localLoki, and generalise the comment at :13 to both destinations.
  3. Add a "since #" note to task-1129-...md:17, and changelog.d/<issue>.md under ### Fixed; cite fix(k8s): k8s-monitoring collectors run in the chart's preset shapes, and node-exporter keeps the series the node dashboards read #1500's unfiled follow-up as the origin.
  4. Argo CD applies it after the release merges into main; each stream's label set changes once, and queries keyed on cluster are unaffected. Check afterwards that {k8s_cluster_name=~".+"} returns no new streams.

Priority: P3. Severity low: a consistency fix with a one-line change.

Activity

  1. added
    source/agent
    type/bug
    on Oct 18, 2026
  2. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/bug. The candidate fixes an inconsistency in how cluster labels are written to Loki versus Prometheus, which is a behavioral bug.
    • Priority: P3-Low. It's a consistency fix with minimal impact and low severity.
    • Value: Low. The change improves consistency but does not affect core functionality or user experience significantly.
    • Effort: Low. The fix involves only adding one line to configuration and updating tests, with no major code changes.
  3. dan-petty commented on Oct 23, 2026

    @dan-petty
    OwnerAuthor

    Delivered by #1958: the k8s-monitoring Loki and Pyroscope destinations set clusterLabels: [cluster], so logs and profiles carry cluster once, as the metrics do.

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

    source/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions