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

[Bug] VX-268: Use exported_node to query metric fome node-exporter #249

Merged
merged 2 commits into from
Aug 16, 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
2 changes: 1 addition & 1 deletion deploy/helm/config/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ services:
pvc:
volumeType: nfs
nfsPath: /nfsshare
nfsServer: 172.17.8.100
nfsServer: 10.1.14.86
reclaimPolicy: Recycle
accessModes: ReadWriteMany
storageClass: mongo
Expand Down
56 changes: 33 additions & 23 deletions src/prometheuscontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func ListNodeName(sp *serviceprovider.Container, queryLabels map[string]string)

nodeList := []string{}
for _, result := range results {
nodeList = append(nodeList, string(result.Metric["node"]))
nodeList = append(nodeList, string(result.Metric["exported_node"]))
}

return nodeList, nil
Expand Down Expand Up @@ -553,11 +553,10 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
expression.Metrics = []string{
"kube_node_info",
"kube_node_created",
"node_network_interface",
"kube_node_labels",
"kube_node_status_capacity.*",
"kube_node_status_allocatable.*"}
expression.QueryLabels = map[string]string{"node": id}
expression.QueryLabels = map[string]string{"exported_node": id}

str := basicExpr(expression.Metrics)
str = queryExpr(str, expression.QueryLabels)
Expand Down Expand Up @@ -586,24 +585,6 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
}
}

case "node_network_interface":
nic := entity.NICMetrics{}
defaultValue, err := strconv.ParseBool(string(result.Metric["default"]))
if err != nil {
return node, err
}
nic.Default = defaultValue
dpdkValue, err := strconv.ParseBool(string(result.Metric["dpdk"]))
if err != nil {
return node, err
}
nic.DPDK = dpdkValue
nic.Type = string(result.Metric["type"])
nic.IP = string(result.Metric["ip_address"])
nic.PCIID = string(result.Metric["pci_id"])
nic.NICNetworkTraffic = entity.NICNetworkTrafficMetrics{}
node.NICs[string(result.Metric["device"])] = nic

case "kube_node_status_allocatable_cpu_cores":
node.Resource.AllocatableCPU = float32(result.Value)

Expand All @@ -624,10 +605,39 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
}
}

// nics
expression = Expression{}
expression.Metrics = []string{"node_network_interface"}
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
}

nic := entity.NICMetrics{}
defaultValue, err := strconv.ParseBool(string(results[0].Metric["default"]))
if err != nil {
return node, err
}
nic.Default = defaultValue
dpdkValue, err := strconv.ParseBool(string(results[0].Metric["dpdk"]))
if err != nil {
return node, err
}
nic.DPDK = dpdkValue
nic.Type = string(results[0].Metric["type"])
nic.IP = string(results[0].Metric["ip_address"])
nic.PCIID = string(results[0].Metric["pci_id"])
nic.NICNetworkTraffic = entity.NICNetworkTrafficMetrics{}
node.NICs[string(results[0].Metric["device"])] = nic

// status
expression = Expression{}
expression.Metrics = []string{"kube_node_status_condition"}
expression.QueryLabels = map[string]string{"node": id, "status": "true"}
expression.QueryLabels = map[string]string{"exported_node": id, "status": "true"}

str = basicExpr(expression.Metrics)
str = queryExpr(str, expression.QueryLabels)
Expand All @@ -644,7 +654,7 @@ func GetNode(sp *serviceprovider.Container, id string) (entity.NodeMetrics, erro
expression.Metrics = []string{
"kube_pod_container_resource_limits.*",
"kube_pod_container_resource_requests.*"}
expression.QueryLabels = map[string]string{"node": id}
expression.QueryLabels = map[string]string{"exported_node": id}
expression.SumByLabels = []string{"__name__", "resource"}

str = basicExpr(expression.Metrics)
Expand Down