← Back to Pull requests

fix: replace kube-state-metrics with kubelet as PrometheusJobUp anchor #5733

Closed
unknown closed this pull request without merging on Jun 21, 2026 08:19 UTC
View on GitHub
unknown unknown commented on Jun 20, 2026 18:54 UTC
Author

Jira: https://redhat.atlassian.net/browse/AROSLSRE-1237

Summary

  • Fix PrometheusJobUp — its cluster anchor was up{job="kube-state-metrics"}, which our own Prometheus scrapes, so a dead Prometheus pod killed the anchor and the alert never fired. Swap to up{job="kubelet"} (scraped by AMA — Azure Monitor Agent — independent of our Prometheus).

  • Remove PrometheusMetricsAbsent — it permanently fired on the HCP workspace, carried no cluster label for IcM, and only fires if all svc and mgmt clusters in a region lose metrics at the same time; PrometheusJobUp + PrometheusUptime already cover it per-cluster.
  • Why — PrometheusJobUp was silent for the exact failure it guards

    PrometheusJobUp uses an unless on(cluster) expression to detect clusters where Prometheus is absent. The left-hand side is the cluster anchor — a series that must survive when Prometheus itself is down.

    The previous anchor, up{job="kube-state-metrics"}, is scraped by our Prometheus pod: those series carry prometheus=prometheus/prometheus and prometheus_replica=prom-agent-prometheus-0, both stamped by the Prometheus operator to identify the scraper. When the Prometheus pod dies it stops scraping kube-state-metrics too, so both sides of the unless disappear simultaneously and the alert is permanently silent — the exact failure mode it exists to catch.

    The fix

    Replace the anchor with up{job="kubelet"}, written by AMA (Azure Monitor Agent) — a separate DaemonSet deployed by Azure as part of the AKS managed-Prometheus add-on. AMA scrapes kubelet independently of our Prometheus installation (confirmed by the absence of any prometheus= label on those series; AMA uses its own remote-write path to the AMW). When our Prometheus pod dies, AMA keeps writing kubelet metrics, so the anchor survives and the unless fires with a real cluster label — so the IcM title and correlationId resolve to the affected cluster instead of rendering empty.

    # Before — anchor dies with Prometheus, alert never fires:
    group by (cluster) (up{job="kube-state-metrics"})
      unless on(cluster) group by (cluster) (up{job="prometheus/prometheus",namespace="prometheus"} == 1)
    
    # After — anchor is AMA-written, survives a Prometheus outage:
    group by (cluster) (up{job="kubelet"})
      unless on(cluster) group by (cluster) (up{job="prometheus/prometheus",namespace="prometheus"} == 1)
    

    Why — PrometheusMetricsAbsent was removed

    A hand-written Bicep alert watching absent(up{job="prometheus/prometheus",namespace="prometheus"}), scoped to both the services and HCP Azure Monitor Workspaces. It was broken in three independent ways and added no coverage beyond existing alerts:

    1. The HCP-scoped instance fired permanently. That metric is never remote-written to the HCP AMW by design — the Prometheus pod writes its self-scrape only to the services AMW — so the alert fired from the moment it deployed, regardless of any cluster's actual health.
    2. No cluster context for IcM. absent() produces a synthetic series carrying only the labels written literally in its selector (job, namespace) — no cluster. The alert also wired no actionProperties, so IcM could not say which cluster was affected.
    3. Useless at scale. On a workspace shared by many clusters, absent() only fires when every cluster stops writing at once. As management clusters scale to ~10 per region, the chance of it catching a real single-cluster outage approaches zero.

    PrometheusJobUp (now fixed above) and PrometheusUptime already cover these failure modes per-cluster with correct IcM routing, so the alert was dropped rather than patched.

    Future improvement

    Once #5732 (underlay_clusters source-of-truth metric) is merged and confirmed in production, the PrometheusJobUp anchor should become underlay_clusters{} — the deploy-time declaration of which clusters should exist. That makes absence detection independent of any runtime scrape state (even AMA being down would not produce a false negative). A TODO comment in the YAML points at this.

    🤖 Generated with Claude Code

    Diff: 520 lines (+390 / -130) across 6 files Reviewer: mmazur Review duration: 804m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.71) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 520 lines diff across 6 files
    0.71
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    57%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.071
    Real PR Conversation Timeline
    1 comments
    "Review active on #5733"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 70.9% (HIGH) · Higher = larger blast radius
    70.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 58.0% · Lower = rushed or shallow review
    58.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.8% · Safe to merge
    29.8%
    Repository