Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] VX-273: Report container version and hugepages resource #263

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/entity/metrics_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ type NICOverviewMetrics struct {

// NodeResourceMetrics is the structure for node resource metrics
type NodeResourceMetrics struct {
CPURequests float32 `json:"cpuRequests"`
CPULimits float32 `json:"cpuLimits"`
MemoryRequests float32 `json:"memoryRequests"`
MemoryLimits float32 `json:"memoryLimits"`
AllocatableCPU float32 `json:"allocatableCPU"`
AllocatableMemory float32 `json:"allocatableMemory"`
AllocatablePods float32 `json:"allocatablePods"`
CapacityCPU float32 `json:"capacityCPU"`
CapacityMemory float32 `json:"capacityMemory"`
CapacityPods float32 `json:"capacityPods"`
CPURequests float32 `json:"cpuRequests"`
CPULimits float32 `json:"cpuLimits"`
MemoryRequests float32 `json:"memoryRequests"`
MemoryLimits float32 `json:"memoryLimits"`
MemoryTotalHugepages float32 `json:"memoryTotalHugepages"`
MemoryFreeHugepages float32 `json:"memoryFreeHugepages"`
AllocatableCPU float32 `json:"allocatableCPU"`
AllocatableMemory float32 `json:"allocatableMemory"`
AllocatablePods float32 `json:"allocatablePods"`
CapacityCPU float32 `json:"capacityCPU"`
CapacityMemory float32 `json:"capacityMemory"`
CapacityPods float32 `json:"capacityPods"`
}

// NodeDetailMetrics is the structure for node detail metrics
Expand All @@ -56,6 +58,7 @@ type NodeDetailMetrics struct {
Status string `json:"status"`
OS string `json:"os"`
KernelVersion string `json:"kernelVersion"`
ContainerVersion string `json:"containerVersion"`
KubeproxyVersion string `json:"kubeproxyVersion"`
KubernetesVersion string `json:"kubernetesVersion"`
Labels map[string]string `json:"labels"`
Expand Down
27 changes: 26 additions & 1 deletion src/prometheuscontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
case "kube_node_info":
node.Detail.Hostname = id
node.Detail.KernelVersion = string(result.Metric["kernel_version"])
node.Detail.ContainerVersion = strings.Split(string(result.Metric["container_runtime_version"]), "//")[1]
node.Detail.KubeproxyVersion = string(result.Metric["kubeproxy_version"])
node.Detail.OS = string(result.Metric["os_image"])
node.Detail.KubernetesVersion = string(result.Metric["kubelet_version"])
Expand Down Expand Up @@ -652,7 +653,7 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro

node.Detail.Status = string(results[0].Metric["condition"])

// resource
// resource reported from kube-state-metrics
expression = Expression{}
expression.Metrics = []string{
"kube_pod_container_resource_limits.*",
Expand Down Expand Up @@ -684,6 +685,30 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
}
}

// resource resported form node-exporter
expression = Expression{}
expression.Metrics = []string{
"node_memory_HugePages_Total",
"node_memory_HugePages_Free"}
expression.QueryLabels = map[string]string{"node": id}

str = basicExpr(expression.Metrics)
str = queryExpr(str, expression.QueryLabels)
results, err = query(sp, str)
if err != nil {
return node, err
}

for _, result := range results {
switch result.Metric["__name__"] {
case "node_memory_HugePages_Total":
node.Resource.MemoryTotalHugepages = float32(result.Value)

case "node_memory_HugePages_Free":
node.Resource.MemoryFreeHugepages = float32(result.Value)
}
}

// network traffic receive bytes
expression.Metrics = []string{"node_network_receive_bytes_total"}
expression.QueryLabels = map[string]string{"node": id}
Expand Down