Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
add node info
Browse files Browse the repository at this point in the history
  • Loading branch information
vikramraman committed Sep 21, 2020
1 parent 8dce8f1 commit 5340f13
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ These are cluster level metrics about the state of Kubernetes objects collected
| HorizontalPodAutoscaler | hpa.current_replicas | Current number of replicas of pods managed by this autoscaler, as last seen by the autoscaler. |
| Node | node.status.condition | Status of all running nodes. |
| Node | node.spec.taint | Node taints (one metric per node taint). |
| Node | node.info | Detailed node information (kernel version, kubelet version etc). |

## Prometheus Source
Varies by scrape target.
Expand Down
19 changes: 19 additions & 0 deletions plugins/sources/kstate/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func pointsForNode(item interface{}, transforms configuration.Transforms) []*met
now := time.Now().Unix()
points := buildNodeConditions(node, transforms, now)
points = append(points, buildNodeTaints(node, transforms, now)...)
points = append(points, buildNodeInfo(node, transforms, now))
return points
}

Expand Down Expand Up @@ -52,6 +53,24 @@ func buildNodeTaints(node *v1.Node, transforms configuration.Transforms, ts int6
return points
}

func buildNodeInfo(node *v1.Node, transforms configuration.Transforms, ts int64) *metrics.MetricPoint {
tags := buildTags("nodename", node.Name, "", transforms.Tags)
copyLabels(node.GetLabels(), tags)
tags["kernel_version"] = node.Status.NodeInfo.KernelVersion
tags["os_image"] = node.Status.NodeInfo.OSImage
tags["container_runtime_version"] = node.Status.NodeInfo.ContainerRuntimeVersion
tags["kubelet_version"] = node.Status.NodeInfo.KubeletVersion
tags["kubeproxy_version"] = node.Status.NodeInfo.KubeProxyVersion
tags["provider_id"] = node.Spec.ProviderID
tags["pod_cidr"] = node.Spec.PodCIDR
for _, address := range node.Status.Addresses {
if address.Type == "InternalIP" {
tags["internal_ip"] = address.Address
}
}
return metricPoint(transforms.Prefix, "node.info", 1.0, ts, transforms.Source, tags)
}

func nodeConditionFloat64(status v1.ConditionStatus) float64 {
switch status {
case v1.ConditionTrue:
Expand Down

0 comments on commit 5340f13

Please sign in to comment.