fix: correct metrics expression

This commit is contained in:
fengzixu 2021-10-24 15:59:32 +09:00
parent d71e21e01e
commit bab1755274
4 changed files with 10 additions and 7 deletions

View File

@ -63,7 +63,7 @@ var (
) )
volumeStatsHealthAbnormalDesc = metrics.NewDesc( volumeStatsHealthAbnormalDesc = metrics.NewDesc(
metrics.BuildFQName("", kubeletmetrics.KubeletSubsystem, kubeletmetrics.VolumeStatsHealthAbnormalKey), metrics.BuildFQName("", kubeletmetrics.KubeletSubsystem, kubeletmetrics.VolumeStatsHealthStatusKey),
"Volume health status. The count is either 1 or 0", "Volume health status. The count is either 1 or 0",
[]string{"namespace", "persistentvolumeclaim"}, nil, []string{"namespace", "persistentvolumeclaim"}, nil,
metrics.ALPHA, "") metrics.ALPHA, "")
@ -127,7 +127,7 @@ func (collector *volumeStatsCollector) CollectWithStability(ch chan<- metrics.Me
addGauge(volumeStatsInodesDesc, pvcRef, float64(*volumeStat.Inodes)) addGauge(volumeStatsInodesDesc, pvcRef, float64(*volumeStat.Inodes))
addGauge(volumeStatsInodesFreeDesc, pvcRef, float64(*volumeStat.InodesFree)) addGauge(volumeStatsInodesFreeDesc, pvcRef, float64(*volumeStat.InodesFree))
addGauge(volumeStatsInodesUsedDesc, pvcRef, float64(*volumeStat.InodesUsed)) addGauge(volumeStatsInodesUsedDesc, pvcRef, float64(*volumeStat.InodesUsed))
addGauge(volumeStatsHealthAbnormalDesc, pvcRef, float64(convertBoolToFloat64(volumeStat.Abnormal))) addGauge(volumeStatsHealthAbnormalDesc, pvcRef, convertBoolToFloat64(volumeStat.Abnormal))
allPVCs.Insert(pvcUniqStr) allPVCs.Insert(pvcUniqStr)
} }
} }

View File

@ -47,8 +47,8 @@ func TestVolumeStatsCollector(t *testing.T) {
# TYPE kubelet_volume_stats_inodes_used gauge # TYPE kubelet_volume_stats_inodes_used gauge
# HELP kubelet_volume_stats_used_bytes [ALPHA] Number of used bytes in the volume # HELP kubelet_volume_stats_used_bytes [ALPHA] Number of used bytes in the volume
# TYPE kubelet_volume_stats_used_bytes gauge # TYPE kubelet_volume_stats_used_bytes gauge
# HELP kubelet_volume_stats_health_abnormal [ALPHA] Volume health status. The count is either 1 or 0 # HELP kubelet_volume_stats_health_status [ALPHA] Volume health status. The count is either 1 or 0
# TYPE kubelet_volume_stats_health_abnormal gauge # TYPE kubelet_volume_stats_health_status gauge
` `
var ( var (
@ -126,7 +126,7 @@ func TestVolumeStatsCollector(t *testing.T) {
kubelet_volume_stats_inodes_free{namespace="testns",persistentvolumeclaim="testpvc"} 655344 kubelet_volume_stats_inodes_free{namespace="testns",persistentvolumeclaim="testpvc"} 655344
kubelet_volume_stats_inodes_used{namespace="testns",persistentvolumeclaim="testpvc"} 16 kubelet_volume_stats_inodes_used{namespace="testns",persistentvolumeclaim="testpvc"} 16
kubelet_volume_stats_used_bytes{namespace="testns",persistentvolumeclaim="testpvc"} 4.21789696e+09 kubelet_volume_stats_used_bytes{namespace="testns",persistentvolumeclaim="testpvc"} 4.21789696e+09
kubelet_volume_stats_health_abnormal{namespace="testns",persistentvolumeclaim="testpvc"} 1 kubelet_volume_stats_health_status{namespace="testns",persistentvolumeclaim="testpvc"} 1
` `
metrics = []string{ metrics = []string{
@ -136,7 +136,7 @@ func TestVolumeStatsCollector(t *testing.T) {
"kubelet_volume_stats_inodes_free", "kubelet_volume_stats_inodes_free",
"kubelet_volume_stats_inodes_used", "kubelet_volume_stats_inodes_used",
"kubelet_volume_stats_used_bytes", "kubelet_volume_stats_used_bytes",
"kubelet_volume_stats_health_abnormal", "kubelet_volume_stats_health_status",
} }
) )

View File

@ -53,7 +53,7 @@ const (
VolumeStatsInodesKey = "volume_stats_inodes" VolumeStatsInodesKey = "volume_stats_inodes"
VolumeStatsInodesFreeKey = "volume_stats_inodes_free" VolumeStatsInodesFreeKey = "volume_stats_inodes_free"
VolumeStatsInodesUsedKey = "volume_stats_inodes_used" VolumeStatsInodesUsedKey = "volume_stats_inodes_used"
VolumeStatsHealthAbnormalKey = "volume_stats_health_abnormal" VolumeStatsHealthStatusKey = "volume_stats_health_status"
RunningPodsKey = "running_pods" RunningPodsKey = "running_pods"
RunningContainersKey = "running_containers" RunningContainersKey = "running_containers"
// Metrics keys of remote runtime operations // Metrics keys of remote runtime operations

View File

@ -230,6 +230,9 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
"test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{ "test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{
"Name": gomega.Equal("test-empty-dir"), "Name": gomega.Equal("test-empty-dir"),
"PVCRef": gomega.BeNil(), "PVCRef": gomega.BeNil(),
"VolumeHealthStats": gstruct.MatchAllFields(gstruct.Fields{
"Abnormal": gomega.BeTrue(),
}),
"FsStats": gstruct.MatchAllFields(gstruct.Fields{ "FsStats": gstruct.MatchAllFields(gstruct.Fields{
"Time": recent(maxStatsAge), "Time": recent(maxStatsAge),
"AvailableBytes": fsCapacityBounds, "AvailableBytes": fsCapacityBounds,