Skip to content

Commit

Permalink
Merge pull request #37 from getupcloud/runtime-imagefs
Browse files Browse the repository at this point in the history
Add support for runtime ImageFS metrics
  • Loading branch information
george-angel authored Sep 28, 2023
2 parents 3930af0 + 2ce7c64 commit 7ce53a0
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ cluster set in kube config.
| kube_summary_pod_ephemeral_storage_inodes_free | Number of available Inodes for pod Ephemeral storage | pod, namespace |
| kube_summary_pod_ephemeral_storage_inodes | Number of Inodes for pod Ephemeral storage | pod, namespace |
| kube_summary_pod_ephemeral_storage_inodes_used | Number of used Inodes for pod Ephemeral storage | pod, namespace |
| kube_summary_node_runtime_imagefs_available_bytes | Number of bytes of node Runtime ImageFS that aren't consumed | node |
| kube_summary_node_runtime_imagefs_capacity_bytes | Number of bytes of node Runtime ImageFS that can be consumed | node |
| kube_summary_node_runtime_imagefs_used_bytes | Number of bytes of node Runtime ImageFS that are consumed | node |
| kube_summary_node_runtime_imagefs_inodes_free | Number of available Inodes for node Runtime ImageFS | node |
| kube_summary_node_runtime_imagefs_inodes | Number of Inodes for node Runtime ImageFS | node |
| kube_summary_node_runtime_imagefs_inodes_used | Number of used Inodes for node Runtime ImageFS | node |
83 changes: 83 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,60 @@ func collectSummaryMetrics(summary *stats.Summary, registry *prometheus.Registry
"namespace",
},
)
nodeRuntimeImageFSAvailableBytes = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Name: "node_runtime_imagefs_available_bytes",
Help: "Number of bytes of node Runtime ImageFS that aren't consumed",
},
[]string{
"node",
},
)
nodeRuntimeImageFSCapacityBytes = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Name: "node_runtime_imagefs_capacity_bytes",
Help: "Number of bytes of node Runtime ImageFS that can be consumed",
},
[]string{
"node",
},
)
nodeRuntimeImageFSUsedBytes = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Name: "node_runtime_imagefs_used_bytes",
Help: "Number of bytes of node Runtime ImageFS that are consumed",
},
[]string{
"node",
},
)
nodeRuntimeImageFSInodesFree = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Name: "node_runtime_imagefs_inodes_free",
Help: "Number of available Inodes for node Runtime ImageFS",
},
[]string{
"node",
},
)
nodeRuntimeImageFSInodes = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Name: "node_runtime_imagefs_inodes",
Help: "Number of Inodes for node Runtime ImageFS",
},
[]string{
"node",
},
)
nodeRuntimeImageFSInodesUsed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Name: "node_runtime_imagefs_inodes_used",
Help: "Number of used Inodes for node Runtime ImageFS",
},
[]string{
"node",
},
)
)
registry.MustRegister(
containerLogsInodesFree,
Expand All @@ -239,6 +293,12 @@ func collectSummaryMetrics(summary *stats.Summary, registry *prometheus.Registry
podEphemeralStorageInodesFree,
podEphemeralStorageInodes,
podEphemeralStorageInodesUsed,
nodeRuntimeImageFSAvailableBytes,
nodeRuntimeImageFSCapacityBytes,
nodeRuntimeImageFSUsedBytes,
nodeRuntimeImageFSInodesFree,
nodeRuntimeImageFSInodes,
nodeRuntimeImageFSInodesUsed,
)

for _, pod := range summary.Pods {
Expand Down Expand Up @@ -306,6 +366,29 @@ func collectSummaryMetrics(summary *stats.Summary, registry *prometheus.Registry
}
}
}

if runtime := summary.Node.Runtime; runtime != nil {
nodeName := summary.Node.NodeName
if runtime.ImageFs.AvailableBytes != nil {
nodeRuntimeImageFSAvailableBytes.WithLabelValues(nodeName).Set(float64(*runtime.ImageFs.AvailableBytes))
}
if runtime.ImageFs.CapacityBytes != nil {
nodeRuntimeImageFSCapacityBytes.WithLabelValues(nodeName).Set(float64(*runtime.ImageFs.CapacityBytes))
}
if runtime.ImageFs.UsedBytes != nil {
nodeRuntimeImageFSUsedBytes.WithLabelValues(nodeName).Set(float64(*runtime.ImageFs.UsedBytes))
}
if runtime.ImageFs.InodesFree != nil {
nodeRuntimeImageFSInodesFree.WithLabelValues(nodeName).Set(float64(*runtime.ImageFs.InodesFree))
}
if runtime.ImageFs.Inodes != nil {
nodeRuntimeImageFSInodes.WithLabelValues(nodeName).Set(float64(*runtime.ImageFs.Inodes))
}
if runtime.ImageFs.InodesUsed != nil {
nodeRuntimeImageFSInodesUsed.WithLabelValues(nodeName).Set(float64(*runtime.ImageFs.InodesUsed))
}
}

}

// nodeHandler returns metrics for the /stats/summary API of the given node
Expand Down

0 comments on commit 7ce53a0

Please sign in to comment.