add support for parsing custom collectors from the stability framework

Change-Id: I1053b9f6956de571700c95b96e05c4377806a3cc
This commit is contained in:
Han Kang
2022-11-01 13:50:12 -07:00
parent 2ab2698e4c
commit c2f67ac141
7 changed files with 608 additions and 18 deletions

View File

@@ -20,10 +20,10 @@ import (
"sync"
"time"
"k8s.io/apimachinery/pkg/types"
"k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/legacyregistry"
"k8s.io/apimachinery/pkg/types"
kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics"
)
// This const block defines the metric names for the kubelet metrics.
@@ -63,6 +63,27 @@ const (
RunPodSandboxErrorsKey = "run_podsandbox_errors_total"
)
const (
// Subsystem names.
pvControllerSubsystem = "pv_collector"
// Metric names.
totalPVKey = "total_pv_count"
boundPVKey = "bound_pv_count"
unboundPVKey = "unbound_pv_count"
boundPVCKey = "bound_pvc_count"
unboundPVCKey = "unbound_pvc_count"
// Label names.
namespaceLabel = "namespace"
storageClassLabel = "storage_class"
pluginNameLabel = "plugin_name"
volumeModeLabel = "volume_mode"
// String to use when plugin name cannot be determined
pluginNameNotAvailable = "N/A"
)
const (
requestKind = "request_kind"
priorityLevel = "priority_level"
@@ -503,6 +524,38 @@ var (
StabilityLevel: metrics.BETA,
},
)
volumeManagerTotalVolumes = "volume_manager_total_volumes"
_ = metrics.NewDesc(
volumeManagerTotalVolumes,
"Number of volumes in Volume Manager",
[]string{"plugin_name", "state"},
nil,
metrics.STABLE, "",
)
_ = metrics.NewDesc(
metrics.BuildFQName("test", "beta", "desc"),
"Number of volumes in Volume Manager",
nil,
map[string]string{"alalala": "lalalal"},
metrics.BETA, "",
)
_ = metrics.NewDesc(
"test_desc_alpha",
"Number of volumes in Volume Manager",
[]string{"plugin_name", "state"},
map[string]string{"alalala": "lalalal"},
metrics.ALPHA, "",
)
_ = metrics.NewDesc(
metrics.BuildFQName("", kubeletmetrics.KubeletSubsystem, kubeletmetrics.VolumeStatsCapacityBytesKey),
"Capacity in bytes of the volume",
[]string{"namespace", "persistentvolumeclaim"}, nil,
metrics.BETA, "",
)
)
var registerMetrics sync.Once

View File

@@ -185,6 +185,13 @@
- 119.20928955078125
- 298.0232238769531
- 745.0580596923828
- name: kubelet_volume_stats_capacity_bytes
help: Capacity in bytes of the volume
type: Custom
stabilityLevel: BETA
labels:
- namespace
- persistentvolumeclaim
- name: priority_level_seat_utilization
subsystem: subsystem
namespace: namespace
@@ -210,6 +217,12 @@
- 1
constLabels:
phase: executing
- name: test_beta_desc
help: Number of volumes in Volume Manager
type: Custom
stabilityLevel: BETA
constLabels:
alalala: lalalal
- name: label
subsystem: const
namespace: test
@@ -281,3 +294,10 @@
- 2.5
- 5
- 10
- name: volume_manager_total_volumes
help: Number of volumes in Volume Manager
type: Custom
stabilityLevel: STABLE
labels:
- plugin_name
- state