feat: add cortex evalution kpis - #1057
Conversation
Signed-off-by: Markus Wieland <44964229+SoWieMarkus@users.noreply.github.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Test Coverage ReportTest Coverage 📊: 70.3% |
There was a problem hiding this comment.
Pull request overview
This PR extends the infrastructure KPI plugin to enrich KVM host metrics with additional host metadata (cluster/building block) and introduces an additional metric for “physical” (non-overcommitted) host capacity to support evaluation KPIs.
Changes:
- Add
compute_clusteras an additional label for KVM host metrics. - Derive
building_block(and cluster) from Hypervisor CR labels instead of parsing the host name. - Add a new Prometheus metric for per-host physical capacity and related helper logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/knowledge/kpis/plugins/infrastructure/shared.go | Adds compute_cluster label and switches building block / cluster derivation to Hypervisor object labels; adds a physical-capacity helper. |
| internal/knowledge/kpis/plugins/infrastructure/shared_test.go | Updates unit tests to match the new KVM host label order and new label sources. |
| internal/knowledge/kpis/plugins/infrastructure/kvm_host_capacity.go | Introduces cortex_kvm_host_physical_capacity_total and emits physical-capacity samples during collection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| cpuPhysical, hasCPUPhysical := hypervisor.getPhysicalCapacity(hv1.ResourceCPU) | ||
| ramPhysical, hasRAMPhysical := hypervisor.getPhysicalCapacity(hv1.ResourceMemory) | ||
|
|
||
| if !hasCPUPhysical || !hasRAMPhysical { | ||
| slog.Warn("hypervisor missing physical cpu or ram capacity, skipping", "host", hypervisor.Name) |
| k.totalPhysicalCapacityPerHost = prometheus.NewDesc( | ||
| "cortex_kvm_host_physical_capacity_total", | ||
| "Total physical resource capacity on the KVM hosts (individually by host, ignoring overcommit factor). CPU in vCPUs, memory in bytes.", | ||
| append(kvmHostLabels, "resource"), | ||
| nil, |
First I wanted to create separate metrics, but the infrastructure metrics are literally what we already need. So I added the missing labels / metrics to the infrastructure package (which also fits in my opinion)
compute_clusterlabel to kvm host metricsbblabel of hypervisor crd instead of manually extracting the bb from the nameWIP