---
id: w3/m10/t002
title: "Disk usage series: PVC usage for managed Postgres/Key Value volumes via cAdvisor/CSI metrics"
worker: worker3
status: todo
estimate: 45m
depends_on: []
---

## Objective

Add a disk-usage series to the metrics API for managed Postgres and Key Value instances, sourced from their backing PVCs.

## Context

- Managed Postgres (`w1/m17`, CNPG) and Key Value (`w1/m14`, Valkey StatefulSet) both back onto PersistentVolumeClaims.
- `docs/ADR002-architecture.md` notes hcloud-csi network volumes; cAdvisor/kubelet volume-stats or CSI metrics expose usage.

## Steps

1. Query PVC usage (bytes used / capacity) via cAdvisor's volume stats or the CSI driver's metrics for a given database/KV instance's PVC.
2. Add a `disk` series to the resource-metrics API for Postgres/KV resources (REST/GraphQL/MCP).
3. Omit or 503 gracefully for resource types with no backing volume (e.g. plain web services).

## Files

- `lego/backend/internal/metrics/`

## Acceptance criteria

- [ ] A real managed-Postgres/KV instance returns live disk usage/capacity.
- [ ] Web services (no PVC) don't return a disk series.

## Out of scope

- Disk usage for tenant App ephemeral storage (bex is stateless-first per `DO_NOT_DO.md`'s "no persistent disks" non-goal — this is only about managed-datastore PVCs, which already exist).
