Skip to content

feat(k8s): coredns metrics and a coredns dashboard #822

Closed

Description

@dan-petty

Context & Rationale

The repo defines no CoreDNS scrape:

  • k8s/coredns/ only sets resource limits.
  • Alloy's clusterMetrics.kubeDNS is off by default (cached k8s-monitoring 4.5.2), and k8s/monitoring/k8s-monitoring-values.yaml:18-40 doesn't turn it on.

Whether CoreDNS is scraped anyway is unknown:

  • The server's kubernetes-service-endpoints job is on (prometheus-values.yaml:60-64). It scrapes any Service annotated prometheus.io/scrape, and k3s's kube-dns Service may carry that annotation for port 9153 (unverified).
  • If the monitoring NetworkPolicy is applied, its kube-system egress allows only ports 53, 443, 6443, 8443, 9100 and 10250 (k8s/monitoring/networkpolicy.yaml:58-90), which would block 9153. deploy-stack doesn't apply that policy (stack_lifecycle.py:130-145, 740).

In-cluster DNS failures, such as NXDOMAIN or SERVFAIL bursts and slow upstreams, may be invisible today.

Scope & Deliverables

  • Deliverable:
    • First, on the homelab, run devops prometheus query 'up{service="kube-dns"}' and devops prometheus query 'sum(rate(coredns_dns_requests_total[5m]))', and record the results.
    • Make exactly one scrape path explicit and allowed (see the key question), and allow monitoring egress to kube-system:9153.
    • Add a CoreDNS dashboard built over captured coredns_* series:
      • requests by type and protocol;
      • responses by rcode;
      • request duration p50/p95/p99;
      • cache hits and misses;
      • forward request duration.
    • Add a CoreDNS capture to feat(k8s): llm gateway, otel collector and prometheus dashboards over metrics the cluster collects (k8s/monitoring/dashboards/) #693's dashboard test.
  • Acceptance criteria:
    • The chosen scrape job's up series reads 1 through devops prometheus query, and sum(rate(coredns_dns_requests_total[5m])) returns a value.
    • Every panel returns data on the homelab.
    • The dashboard test covers the CoreDNS names and labels.
  • Key questions: Which scrape path? (proposed) If the server already scrapes kube-dns, keep that job and only open egress on 9153. Otherwise, enable Alloy's clusterMetrics.kubeDNS. Never enable both, to avoid duplicate series.
  • Constraint: Tests never touch the network.

Strategic Alignment

Monitoring cleanup amendment (2026-10-03)

Answer to the open question (checked 2026-10-03). The Prometheus server's kubernetes-service-endpoints job already scrapes kube-system/kube-dns:9153. It is that job's only active target. #1130 disables the job and turns on clusterMetrics.kubeDNS in the same change, so CoreDNS is never scraped twice, and it adds the monitoring egress rule for kube-system 9153 that the Alloy collector then needs.

After #1130, this item's remaining scope is the dashboard (and any CoreDNS alert), built on job="integrations/kubernetes/kube-dns". It lands after #1130.

Grouping. This item is a child of #1128 (monitoring cleanup), not of #551.

Activity

  1. added
    type/feature
    scope/k8s
    priority/p3-low
    on Oct 1, 2026
  2. added this to the v0.2.38 milestone on Oct 21, 2026
  3. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    Checked on release/v0.2.38 at 14d4490, 2026-10-22. The code scope of this item is delivered:

    Pending a person: on the homelab, devops prometheus query 'up{job="integrations/kubernetes/kube-dns"}' reads 1, sum(rate(coredns_dns_requests_total[5m])) returns a value, and every dashboard panel returns data. No code remains for this item; a CoreDNS alert, which the amendment calls optional, was not added.

  4. added a commit that references this issue on Oct 21, 2026
    ddf7a0f
  5. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1795, merged into release/v0.2.38 as ddf7a0f.

    Closes #822

    5 file(s) changed.

    How it was verified

    Check runs at 7c9bc43:

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

    Acceptance Criteria of docs/agent/tasks/task-822-coredns-metrics-and-dashboard.md:

    • up{service="kube-dns"} (job="integrations/kubernetes/kube-dns") reads 1 through devops prometheus query, and sum(rate(coredns_dns_requests_total[5m])) returns a live value (2.025).
    • Every panel in k8s/monitoring/dashboards/coredns.json returns data on the cluster.
    • tests/test_stack_dashboards.py covers the CoreDNS metric names, label names, and single explicit scrape path (_coredns_monitored).
    • tests/test_k8s_monitoring_alerting.py verifies CoreDnsServfailResponses in homelab-services against SERVED_SERIES.
  6. added 2 commits that reference this issue on Oct 21, 2026
    1a8b26c
    f92399e
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/p3-lowscope/k8stype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions