Skip to content

Commit

Permalink
Merge pull request #230 from linkernetworks/phstsai/VX-256
Browse files Browse the repository at this point in the history
[Bug] VX-256: Modify the metrics name in get node handler
  • Loading branch information
John-Lin authored Aug 8, 2018
2 parents 148cf67 + 1dc9b33 commit 3a7adf1
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions src/prometheuscontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
"kube_node_created",
"node_network_interface",
"kube_node_labels",
"kube_node_status_capacity",
"kube_node_status_allocatable"}
"kube_node_status_capacity.*",
"kube_node_status_allocatable.*"}
expression.QueryLabels = map[string]string{"node": id}

str := basicExpr(expression.Metrics)
Expand Down Expand Up @@ -604,25 +604,23 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
nic.NICNetworkTraffic = entity.NICNetworkTrafficMetrics{}
node.NICs[string(result.Metric["device"])] = nic

case "kube_node_status_allocatable":
switch result.Metric["resource"] {
case "cpu":
node.Resource.AllocatableCPU = float32(result.Value)
case "memory":
node.Resource.AllocatableMemory = float32(result.Value)
case "pods":
node.Resource.AllocatablePods = float32(result.Value)
}
case "kube_node_status_allocatable_cpu_cores":
node.Resource.AllocatableCPU = float32(result.Value)

case "kube_node_status_capacity":
switch result.Metric["resource"] {
case "cpu":
node.Resource.CapacityCPU = float32(result.Value)
case "memory":
node.Resource.CapacityMemory = float32(result.Value)
case "pods":
node.Resource.CapacityPods = float32(result.Value)
}
case "kube_node_status_allocatable_memory_bytes":
node.Resource.AllocatableMemory = float32(result.Value)

case "kube_node_status_allocatable_pods":
node.Resource.AllocatablePods = float32(result.Value)

case "kube_node_status_capacity_cpu_cores":
node.Resource.CapacityCPU = float32(result.Value)

case "kube_node_status_capacity_memory_bytes":
node.Resource.CapacityMemory = float32(result.Value)

case "kube_node_status_capacity_pods":
node.Resource.CapacityPods = float32(result.Value)
}
}

Expand All @@ -644,8 +642,8 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
// resource
expression = Expression{}
expression.Metrics = []string{
"kube_pod_container_resource_limits",
"kube_pod_container_resource_requests"}
"kube_pod_container_resource_limits.*",
"kube_pod_container_resource_requests.*"}
expression.QueryLabels = map[string]string{"node": id}
expression.SumByLabels = []string{"__name__", "resource"}

Expand All @@ -659,20 +657,17 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro

for _, result := range results {
switch result.Metric["__name__"] {
case "kube_pod_container_resource_requests":
switch result.Metric["resource"] {
case "cpu":
node.Resource.CPURequests = float32(result.Value)
case "memory":
node.Resource.MemoryRequests = float32(result.Value)
}
case "kube_pod_container_resource_limits":
switch result.Metric["resource"] {
case "cpu":
node.Resource.CPULimits = float32(result.Value)
case "memory":
node.Resource.MemoryLimits = float32(result.Value)
}
case "kube_pod_container_resource_requests_cpu_cores":
node.Resource.CPURequests = float32(result.Value)

case "kube_pod_container_resource_requests_memory_bytes":
node.Resource.MemoryRequests = float32(result.Value)

case "kube_pod_container_resource_limits_cpu_cores":
node.Resource.CPULimits = float32(result.Value)

case "kube_pod_container_resource_limits_memory_bytes":
node.Resource.MemoryLimits = float32(result.Value)
}
}

Expand Down

0 comments on commit 3a7adf1

Please sign in to comment.