mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 01:23:48 +00:00
add volume type and seperated histogram for volume stat collection
This commit is contained in:
@@ -68,14 +68,13 @@ var (
|
||||
// this metric is mainly for comparison between fsquota monitoring and `du` for disk usage.
|
||||
VolumeStatCalDuration = metrics.NewHistogramVec(
|
||||
&metrics.HistogramOpts{
|
||||
Subsystem: kubeletSubsystem,
|
||||
Name: "volume_stat_cal_duration_seconds",
|
||||
Help: "Duration in seconds to calculate volume stats",
|
||||
// Use DefBuckets for now, will customize the buckets if necessary.
|
||||
Subsystem: kubeletSubsystem,
|
||||
Name: "volume_metric_collection_duration_seconds",
|
||||
Help: "Duration in seconds to calculate volume stats",
|
||||
Buckets: metrics.DefBuckets,
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{},
|
||||
[]string{"metric_source"},
|
||||
)
|
||||
)
|
||||
|
||||
@@ -95,3 +94,8 @@ func Register() {
|
||||
func SinceInSeconds(start time.Time) float64 {
|
||||
return time.Since(start).Seconds()
|
||||
}
|
||||
|
||||
// CollectVolumeStatCalDuration collects the duration in seconds to calculate volume stats.
|
||||
func CollectVolumeStatCalDuration(metricSource string, start time.Time) {
|
||||
VolumeStatCalDuration.WithLabelValues(metricSource).Observe(SinceInSeconds(start))
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ import (
|
||||
"k8s.io/klog/v2"
|
||||
stats "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
servermetrics "k8s.io/kubernetes/pkg/kubelet/server/metrics"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
)
|
||||
@@ -134,13 +133,7 @@ func (s *volumeStatCalculator) calcAndStoreStats() {
|
||||
var ephemeralStats []stats.VolumeStats
|
||||
var persistentStats []stats.VolumeStats
|
||||
for name, v := range metricVolumes {
|
||||
metric, err := func() (*volume.Metrics, error) {
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
servermetrics.VolumeStatCalDuration.WithLabelValues().Observe(servermetrics.SinceInSeconds(startTime))
|
||||
}()
|
||||
return v.GetMetrics()
|
||||
}()
|
||||
metric, err := v.GetMetrics()
|
||||
if err != nil {
|
||||
// Expected for Volumes that don't support Metrics
|
||||
if !volume.IsNotSupported(err) {
|
||||
|
Reference in New Issue
Block a user