Skip to content

Commit c9d8943

Browse files
authored
refactor: vmware host capacity kpi (#775)
1 parent 643ae36 commit c9d8943

10 files changed

Lines changed: 572 additions & 741 deletions

File tree

helm/bundles/cortex-nova/templates/kpis.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ spec:
2929
---
3030
apiVersion: cortex.cloud/v1alpha1
3131
kind: KPI
32-
metadata:
33-
name: vmware-host-capacity
34-
spec:
35-
schedulingDomain: nova
36-
impl: vmware_host_capacity_kpi
37-
dependencies:
38-
knowledges:
39-
- name: host-details
40-
- name: host-utilization
41-
description: |
42-
This KPI tracks the total, utilized, reserved and failover capacity of VMware hosts.
43-
---
44-
apiVersion: cortex.cloud/v1alpha1
45-
kind: KPI
4632
metadata:
4733
name: host-running-vms
4834
spec:
@@ -215,4 +201,18 @@ spec:
215201
- name: nova-flavors
216202
- name: limes-project-commitments
217203
description: |
218-
This KPI tracks the resource commitments of projects running VMs on VMware hosts.
204+
This KPI tracks the resource commitments of projects running VMs on VMware hosts.
205+
---
206+
apiVersion: cortex.cloud/v1alpha1
207+
kind: KPI
208+
metadata:
209+
name: vmware-host-capacity
210+
spec:
211+
schedulingDomain: nova
212+
impl: vmware_host_capacity_kpi
213+
dependencies:
214+
knowledges:
215+
- name: host-details
216+
- name: host-utilization
217+
description: |
218+
This KPI tracks the capacity and utilization of VMware hosts in terms of CPU, RAM, and disk resources.

internal/knowledge/kpis/plugins/compute/resource_capacity_kvm_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package compute
55

66
import (
7+
"regexp"
78
"testing"
89

910
"github.com/cobaltcore-dev/cortex/api/v1alpha1"
@@ -38,6 +39,16 @@ type kvmMetricLabels struct {
3839
Maintenance string
3940
}
4041

42+
var fqNameRe = regexp.MustCompile(`fqName: "([^"]+)"`)
43+
44+
func getMetricName(desc string) string {
45+
match := fqNameRe.FindStringSubmatch(desc)
46+
if len(match) > 1 {
47+
return match[1]
48+
}
49+
return ""
50+
}
51+
4152
type kvmExpectedMetric struct {
4253
Name string // metric family name (e.g. "cortex_kvm_host_capacity_total")
4354
Labels kvmMetricLabels

internal/knowledge/kpis/plugins/compute/resource_capacity_vmware.go

Lines changed: 0 additions & 201 deletions
This file was deleted.

0 commit comments

Comments
 (0)