Skip to content

feat(monitoring): scrape the gateway database and alert on its size #4994

Closed

Description

@dan-petty

Problem or Motivation

The gateway refuses every key when its database is down, so a full claim stops all AI work. Nothing measures the database:

This item is rank 5 of the cluster integration plan #4989. It is a configuration fix that ships now and needs no owner step.

Proposed Solution & Architectural Design

  1. Add a PodMonitor for cnpg.io/cluster=llm-gateway-db (port metrics, 9187), as k8s/mattermost/podmonitor.yaml does.
  2. Add an ingress rule from monitoring on TCP 9187 in the llm-gateway-db-perimeter NetworkPolicy (k8s/llm/gateway-db.yaml).
  3. Copy the CloudNativePG dashboard JSON (cloudnative-pg/grafana-dashboards, Apache-2.0) into k8s/monitoring/dashboards and its configMapGenerator. It must pass docs/DESIGN.md, and the dashboard lint of test(monitoring): lint dashboards for range, window and legend errors #4743 when it lands. The dashboard also serves mattermost-db.
  4. Add rules for one instance, each with a promtool case: collector down, connections near max_connections, and database size plus WAL (cnpg_pg_database_size_bytes + cnpg_collector_pg_wal) against the 5Gi claim.
  5. Set general_settings.maximum_spend_logs_retention_period to 30d in k8s/llm/gateway/config.yaml.

Target Subsystem

Kubernetes & Minikube Automation (k8s/llm/, k8s/monitoring/).

Existing Tool Considered

The CloudNativePG metrics exporter and its upstream dashboard (Apache-2.0), the Prometheus Operator PodMonitor, and the LiteLLM spend-log retention setting. Nothing is built.

Acceptance Criteria

  • After the merge, Prometheus has cnpg_collector_up for llm-gateway-db.
  • promtool cases pass for the three rules.
  • The dashboard shows llm-gateway-db and mattermost-db.
  • The gateway config holds the 30d retention, and a config test holds it.

Dependencies

None.

Source: #4989

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/monitoring
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
    • Related: dan-petty/homelab#332, which asks for a different change. Both items target the llm-gateway-db CloudNativePG cluster, but dan-petty/homelab#332 adds an off-node backup while this candidate adds metrics scraping, a dashboard, and alert rules.
  4. added
    priority/p2-medium
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 12, 2026
  5. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor
  7. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 12:40 UTC

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

    effort/mediumpriority/p2-mediumscope/monitoringsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions