|
|
@@ -179,20 +179,22 @@ func (a *Accesses) recordPrices() {
|
|
|
|
|
|
totalCost := cpu*cpuCost + ramCost*(ram/1024/1024/1024) + gpu*gpuCost
|
|
|
|
|
|
- a.CPUPriceRecorder.WithLabelValues(nodeName).Set(cpuCost)
|
|
|
- a.RAMPriceRecorder.WithLabelValues(nodeName).Set(ramCost)
|
|
|
- a.GPUPriceRecorder.WithLabelValues(nodeName).Set(gpuCost)
|
|
|
+ a.CPUPriceRecorder.WithLabelValues(nodeName, nodeName).Set(cpuCost)
|
|
|
+ a.RAMPriceRecorder.WithLabelValues(nodeName, nodeName).Set(ramCost)
|
|
|
+ if gpu > 0 {
|
|
|
+ a.GPUPriceRecorder.WithLabelValues(nodeName, nodeName).Set(gpuCost)
|
|
|
+ }
|
|
|
|
|
|
- a.NodeTotalPriceRecorder.WithLabelValues(nodeName).Set(totalCost)
|
|
|
+ a.NodeTotalPriceRecorder.WithLabelValues(nodeName, nodeName).Set(totalCost)
|
|
|
|
|
|
namespace := costs.Namespace
|
|
|
podName := costs.PodName
|
|
|
containerName := costs.Name
|
|
|
if len(costs.RAMAllocation) > 0 {
|
|
|
- a.RAMAllocationRecorder.WithLabelValues(namespace, podName, containerName, nodeName).Set(costs.RAMAllocation[0].Value)
|
|
|
+ a.RAMAllocationRecorder.WithLabelValues(namespace, podName, containerName, nodeName, nodeName).Set(costs.RAMAllocation[0].Value)
|
|
|
}
|
|
|
if len(costs.CPUAllocation) > 0 {
|
|
|
- a.CPUAllocationRecorder.WithLabelValues(namespace, podName, containerName, nodeName).Set(costs.CPUAllocation[0].Value)
|
|
|
+ a.CPUAllocationRecorder.WithLabelValues(namespace, podName, containerName, nodeName, nodeName).Set(costs.CPUAllocation[0].Value)
|
|
|
}
|
|
|
}
|
|
|
time.Sleep(time.Minute)
|
|
|
@@ -242,32 +244,32 @@ func main() {
|
|
|
cpuGv := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
Name: "node_cpu_hourly_cost",
|
|
|
Help: "node_cpu_hourly_cost hourly cost for each cpu on this node",
|
|
|
- }, []string{"instance"})
|
|
|
+ }, []string{"instance", "node"})
|
|
|
|
|
|
ramGv := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
Name: "node_ram_hourly_cost",
|
|
|
Help: "node_ram_hourly_cost hourly cost for each gb of ram on this node",
|
|
|
- }, []string{"instance"})
|
|
|
+ }, []string{"instance", "node"})
|
|
|
|
|
|
gpuGv := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
Name: "node_gpu_hourly_cost",
|
|
|
Help: "node_gpu_hourly_cost hourly cost for each gpu on this node",
|
|
|
- }, []string{"instance"})
|
|
|
+ }, []string{"instance", "node"})
|
|
|
|
|
|
totalGv := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
Name: "node_total_hourly_cost",
|
|
|
Help: "node_total_hourly_cost Total node cost per hour",
|
|
|
- }, []string{"instance"})
|
|
|
+ }, []string{"instance", "node"})
|
|
|
|
|
|
RAMAllocation := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
Name: "container_memory_allocation_bytes",
|
|
|
Help: "container_memory_allocation_bytes Bytes of RAM used",
|
|
|
- }, []string{"namespace", "pod", "container", "instance"})
|
|
|
+ }, []string{"namespace", "pod", "container", "instance", "node"})
|
|
|
|
|
|
CPUAllocation := prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
Name: "container_cpu_allocation",
|
|
|
Help: "container_cpu_allocation Percent of a single CPU used in a minute",
|
|
|
- }, []string{"namespace", "pod", "container", "instance"})
|
|
|
+ }, []string{"namespace", "pod", "container", "instance", "node"})
|
|
|
|
|
|
prometheus.MustRegister(cpuGv)
|
|
|
prometheus.MustRegister(ramGv)
|