-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f181af
commit 4f3c651
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
var ( | ||
virtualMachineCount = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Name: "kubemox_virtual_machine_count", | ||
Help: "Number of virtualMachines registered in the cluster", | ||
}) | ||
virtualMachineCPUCores = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "kubemox_virtual_machine_cpu_cores", | ||
Help: "Number of CPU cores of virtualMachine", | ||
}, []string{"name", "namespace"}) | ||
virtualMachineMemory = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "kubemox_virtual_machine_memory", | ||
Help: "Memory of virtualMachine as MB", | ||
}, []string{"name", "namespace"}) | ||
ManagedVirtualMachineCount = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Name: "kubemox_managed_virtual_machine_count", | ||
Help: "Number of managedVirtualMachines exists in Proxmox", | ||
}) | ||
ManagedVirtualMachineCPUCores = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "kubemox_managed_virtual_machine_cpu_cores", | ||
Help: "Number of CPU cores of managedVirtualMachine", | ||
}, []string{"name", "namespace"}) | ||
ManagedVirtualMachineMemory = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "kubemox_managed_virtual_machine_memory", | ||
Help: "Memory of managedVirtualMachine as MB", | ||
}, []string{"name", "namespace"}) | ||
) | ||
|
||
func init() { | ||
metrics.Registry.MustRegister(virtualMachineCount) | ||
metrics.Registry.MustRegister(virtualMachineCPUCores) | ||
metrics.Registry.MustRegister(virtualMachineMemory) | ||
metrics.Registry.MustRegister(ManagedVirtualMachineCount) | ||
metrics.Registry.MustRegister(ManagedVirtualMachineCPUCores) | ||
metrics.Registry.MustRegister(ManagedVirtualMachineMemory) | ||
} | ||
|
||
func IncVirtualMachineCount() { | ||
virtualMachineCount.Inc() | ||
} | ||
|
||
func DecVirtualMachineCount() { | ||
virtualMachineCount.Dec() | ||
} | ||
|
||
func SetVirtualMachineCPUCores(name, namespace string, cores float64) { | ||
virtualMachineCPUCores.WithLabelValues(name, namespace).Set(cores) | ||
} | ||
|
||
func SetVirtualMachineMemory(name, namespace string, memory float64) { | ||
virtualMachineMemory.WithLabelValues(name, namespace).Set(memory) | ||
} | ||
|
||
func IncManagedVirtualMachineCount() { | ||
ManagedVirtualMachineCount.Inc() | ||
} | ||
|
||
func DecManagedVirtualMachineCount() { | ||
ManagedVirtualMachineCount.Dec() | ||
} | ||
|
||
func SetManagedVirtualMachineCPUCores(name, namespace string, cores float64) { | ||
ManagedVirtualMachineCPUCores.WithLabelValues(name, namespace).Set(cores) | ||
} | ||
|
||
func SetManagedVirtualMachineMemory(name, namespace string, memory float64) { | ||
ManagedVirtualMachineMemory.WithLabelValues(name, namespace).Set(memory) | ||
} |