diff --git a/go.mod b/go.mod index 2ec80d7c51..8e45889a6b 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( k8s.io/apimachinery v0.25.2 k8s.io/autoscaler/vertical-pod-autoscaler v0.12.0 k8s.io/client-go v0.25.2 + k8s.io/component-base v0.25.2 k8s.io/klog/v2 v2.80.1 k8s.io/sample-controller v0.25.2 k8s.io/utils v0.0.0-20220922133306-665eaaec4324 @@ -40,6 +41,7 @@ require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.8.0 // indirect diff --git a/go.sum b/go.sum index f1ba051715..08186905a8 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -984,6 +985,8 @@ k8s.io/client-go v0.25.2/go.mod h1:i7cNU7N+yGQmJkewcRD2+Vuj4iz7b30kI8OcL3horQ4= k8s.io/code-generator v0.25.0/go.mod h1:B6jZgI3DvDFAualltPitbYMQ74NjaCFxum3YeKZZ+3w= k8s.io/code-generator v0.25.2/go.mod h1:f61OcU2VqVQcjt/6TrU0sta1TA5hHkOO6ZZPwkL9Eys= k8s.io/component-base v0.25.0/go.mod h1:F2Sumv9CnbBlqrpdf7rKZTmmd2meJq0HizeyY/yAFxk= +k8s.io/component-base v0.25.2 h1:Nve/ZyHLUBHz1rqwkjXm/Re6IniNa5k7KgzxZpTfSQY= +k8s.io/component-base v0.25.2/go.mod h1:90W21YMr+Yjg7MX+DohmZLzjsBtaxQDDwaX4YxDkl60= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20211129171323-c02415ce4185/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= diff --git a/internal/store/certificatesigningrequest.go b/internal/store/certificatesigningrequest.go index bec123b7f2..1b0eae4fcd 100644 --- a/internal/store/certificatesigningrequest.go +++ b/internal/store/certificatesigningrequest.go @@ -19,6 +19,8 @@ package store import ( "context" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -58,10 +60,11 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descCSRLabelsName, descCSRLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapCSRFunc(func(j *certv1.CertificateSigningRequest) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList) @@ -76,10 +79,11 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_certificatesigningrequest_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapCSRFunc(func(csr *certv1.CertificateSigningRequest) *metric.Family { ms := []*metric.Metric{} @@ -96,10 +100,11 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_certificatesigningrequest_condition", "The number of each certificatesigningrequest condition", metric.Gauge, + basemetrics.STABLE, "", wrapCSRFunc(func(csr *certv1.CertificateSigningRequest) *metric.Family { return &metric.Family{ @@ -107,10 +112,11 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_certificatesigningrequest_cert_length", "Length of the issued cert", metric.Gauge, + basemetrics.STABLE, "", wrapCSRFunc(func(csr *certv1.CertificateSigningRequest) *metric.Family { return &metric.Family{ diff --git a/internal/store/certificatesigningrequest_test.go b/internal/store/certificatesigningrequest_test.go index 4849b87363..990061942a 100644 --- a/internal/store/certificatesigningrequest_test.go +++ b/internal/store/certificatesigningrequest_test.go @@ -28,13 +28,13 @@ import ( func TestCsrStore(t *testing.T) { const metadata = ` - # HELP kube_certificatesigningrequest_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_certificatesigningrequest_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_certificatesigningrequest_labels gauge - # HELP kube_certificatesigningrequest_created Unix creation timestamp + # HELP kube_certificatesigningrequest_created [STABLE] Unix creation timestamp # TYPE kube_certificatesigningrequest_created gauge - # HELP kube_certificatesigningrequest_condition The number of each certificatesigningrequest condition + # HELP kube_certificatesigningrequest_condition [STABLE] The number of each certificatesigningrequest condition # TYPE kube_certificatesigningrequest_condition gauge - # HELP kube_certificatesigningrequest_cert_length Length of the issued cert + # HELP kube_certificatesigningrequest_cert_length [STABLE] Length of the issued cert # TYPE kube_certificatesigningrequest_cert_length gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/configmap.go b/internal/store/configmap.go index 8a6e4a172a..2f26a8e7b7 100644 --- a/internal/store/configmap.go +++ b/internal/store/configmap.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -54,10 +55,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_configmap_labels", "Kubernetes labels converted to Prometheus labels.", metric.Gauge, + basemetrics.STABLE, "", wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", c.Labels, allowLabelsList) @@ -72,10 +74,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_configmap_info", "Information about configmap.", metric.Gauge, + basemetrics.STABLE, "", wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family { return &metric.Family{ @@ -87,10 +90,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_configmap_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/configmap_test.go b/internal/store/configmap_test.go index 0cbc08d3bc..aecf13c4d7 100644 --- a/internal/store/configmap_test.go +++ b/internal/store/configmap_test.go @@ -54,8 +54,8 @@ func TestConfigMapStore(t *testing.T) { }, Want: ` # HELP kube_configmap_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_configmap_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_configmap_info Information about configmap. + # HELP kube_configmap_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_configmap_info [STABLE] Information about configmap. # HELP kube_configmap_metadata_resource_version Resource version representing a specific version of the configmap. # TYPE kube_configmap_annotations gauge # TYPE kube_configmap_labels gauge @@ -82,8 +82,8 @@ func TestConfigMapStore(t *testing.T) { }, }, Want: ` - # HELP kube_configmap_created Unix creation timestamp - # HELP kube_configmap_info Information about configmap. + # HELP kube_configmap_created [STABLE] Unix creation timestamp + # HELP kube_configmap_info [STABLE] Information about configmap. # HELP kube_configmap_metadata_resource_version Resource version representing a specific version of the configmap. # TYPE kube_configmap_created gauge # TYPE kube_configmap_info gauge diff --git a/internal/store/cronjob.go b/internal/store/cronjob.go index f7b82deb86..dc762e1b2f 100644 --- a/internal/store/cronjob.go +++ b/internal/store/cronjob.go @@ -29,6 +29,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -62,10 +63,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descCronJobLabelsName, descCronJobLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList) @@ -80,10 +82,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_info", "Info about cronjob.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { return &metric.Family{ @@ -97,10 +100,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { ms := []*metric.Metric{} @@ -117,10 +121,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_status_active", "Active holds pointers to currently running jobs.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { return &metric.Family{ @@ -134,10 +139,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_status_last_schedule_time", "LastScheduleTime keeps information of when was the last time the job was successfully scheduled.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { ms := []*metric.Metric{} @@ -176,10 +182,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_spec_suspend", "Suspend flag tells the controller to suspend subsequent executions.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { ms := []*metric.Metric{} @@ -197,10 +204,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_spec_starting_deadline_seconds", "Deadline in seconds for starting the job if it misses scheduled time for any reason.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { ms := []*metric.Metric{} @@ -219,10 +227,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_next_schedule_time", "Next time the cronjob should be scheduled. The time after lastScheduleTime, or after the cron job's creation time if it's never been scheduled. Use this to determine if the job is delayed.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { ms := []*metric.Metric{} @@ -244,10 +253,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_cronjob_metadata_resource_version", "Resource version representing a specific version of the cronjob.", metric.Gauge, + basemetrics.STABLE, "", wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family { return &metric.Family{ diff --git a/internal/store/cronjob_test.go b/internal/store/cronjob_test.go index 7c1b684fdf..9b992874b2 100644 --- a/internal/store/cronjob_test.go +++ b/internal/store/cronjob_test.go @@ -135,18 +135,18 @@ func TestCronJobStore(t *testing.T) { }, }, Want: ` - # HELP kube_cronjob_created Unix creation timestamp - # HELP kube_cronjob_info Info about cronjob. + # HELP kube_cronjob_created [STABLE] Unix creation timestamp + # HELP kube_cronjob_info [STABLE] Info about cronjob. # HELP kube_cronjob_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_cronjob_next_schedule_time Next time the cronjob should be scheduled. The time after lastScheduleTime, or after the cron job's creation time if it's never been scheduled. Use this to determine if the job is delayed. + # HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_cronjob_next_schedule_time [STABLE] Next time the cronjob should be scheduled. The time after lastScheduleTime, or after the cron job's creation time if it's never been scheduled. Use this to determine if the job is delayed. # HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved. - # HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason. + # HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason. # HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved. - # HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions. - # HELP kube_cronjob_status_active Active holds pointers to currently running jobs. - # HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob. - # HELP kube_cronjob_status_last_schedule_time LastScheduleTime keeps information of when was the last time the job was successfully scheduled. + # HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions. + # HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs. + # HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob. + # HELP kube_cronjob_status_last_schedule_time [STABLE] LastScheduleTime keeps information of when was the last time the job was successfully scheduled. # TYPE kube_cronjob_created gauge # TYPE kube_cronjob_info gauge # TYPE kube_cronjob_annotations gauge @@ -212,16 +212,16 @@ func TestCronJobStore(t *testing.T) { }, }, Want: ` - # HELP kube_cronjob_created Unix creation timestamp - # HELP kube_cronjob_info Info about cronjob. - # HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_cronjob_created [STABLE] Unix creation timestamp + # HELP kube_cronjob_info [STABLE] Info about cronjob. + # HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved. - # HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason. + # HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason. # HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved. - # HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions. - # HELP kube_cronjob_status_active Active holds pointers to currently running jobs. - # HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob. - # HELP kube_cronjob_status_last_schedule_time LastScheduleTime keeps information of when was the last time the job was successfully scheduled. + # HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions. + # HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs. + # HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob. + # HELP kube_cronjob_status_last_schedule_time [STABLE] LastScheduleTime keeps information of when was the last time the job was successfully scheduled. # HELP kube_cronjob_status_last_successful_time LastSuccessfulTime keeps information of when was the last time the job was completed successfully. # TYPE kube_cronjob_created gauge # TYPE kube_cronjob_info gauge @@ -272,16 +272,16 @@ func TestCronJobStore(t *testing.T) { }, }, Want: ` - # HELP kube_cronjob_created Unix creation timestamp - # HELP kube_cronjob_info Info about cronjob. - # HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_cronjob_created [STABLE] Unix creation timestamp + # HELP kube_cronjob_info [STABLE] Info about cronjob. + # HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved. - # HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason. + # HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason. # HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved. - # HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions. - # HELP kube_cronjob_status_active Active holds pointers to currently running jobs. - # HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob. - # HELP kube_cronjob_status_last_schedule_time LastScheduleTime keeps information of when was the last time the job was successfully scheduled. + # HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions. + # HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs. + # HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob. + # HELP kube_cronjob_status_last_schedule_time [STABLE] LastScheduleTime keeps information of when was the last time the job was successfully scheduled. # HELP kube_cronjob_status_last_successful_time LastSuccessfulTime keeps information of when was the last time the job was completed successfully. # TYPE kube_cronjob_created gauge # TYPE kube_cronjob_info gauge @@ -334,17 +334,17 @@ func TestCronJobStore(t *testing.T) { }, }, Want: ` - # HELP kube_cronjob_created Unix creation timestamp - # HELP kube_cronjob_info Info about cronjob. - # HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_cronjob_next_schedule_time Next time the cronjob should be scheduled. The time after lastScheduleTime, or after the cron job's creation time if it's never been scheduled. Use this to determine if the job is delayed. + # HELP kube_cronjob_created [STABLE] Unix creation timestamp + # HELP kube_cronjob_info [STABLE] Info about cronjob. + # HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_cronjob_next_schedule_time [STABLE] Next time the cronjob should be scheduled. The time after lastScheduleTime, or after the cron job's creation time if it's never been scheduled. Use this to determine if the job is delayed. # HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved. - # HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason. + # HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason. # HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved. - # HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions. - # HELP kube_cronjob_status_active Active holds pointers to currently running jobs. + # HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions. + # HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs. # HELP kube_cronjob_status_last_successful_time LastSuccessfulTime keeps information of when was the last time the job was completed successfully. - # HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob. + # HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob. # TYPE kube_cronjob_created gauge # TYPE kube_cronjob_info gauge # TYPE kube_cronjob_labels gauge diff --git a/internal/store/daemonset.go b/internal/store/daemonset.go index aef94427b4..d770cad585 100644 --- a/internal/store/daemonset.go +++ b/internal/store/daemonset.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +41,11 @@ var ( func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { ms := []*metric.Metric{} @@ -61,10 +63,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_current_number_scheduled", "The number of nodes running at least one daemon pod and are supposed to.", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -78,10 +81,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_desired_number_scheduled", "The number of nodes that should be running the daemon pod.", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -95,10 +99,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_number_available", "The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -112,10 +117,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_number_misscheduled", "The number of nodes running a daemon pod but are not supposed to.", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -129,10 +135,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_number_ready", "The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready.", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -146,10 +153,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_number_unavailable", "The number of nodes that should be running the daemon pod and have none of the daemon pod running and available", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -163,10 +171,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_observed_generation", "The most recent generation observed by the daemon set controller.", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -180,10 +189,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_status_updated_number_scheduled", "The total number of nodes that are running updated daemon pod", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -195,10 +205,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_daemonset_metadata_generation", "Sequence number representing a specific generation of the desired state.", metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { return &metric.Family{ @@ -230,10 +241,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descDaemonSetLabelsName, descDaemonSetLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", d.Labels, allowLabelsList) diff --git a/internal/store/daemonset_test.go b/internal/store/daemonset_test.go index e7cea91e79..7a8f06ed3a 100644 --- a/internal/store/daemonset_test.go +++ b/internal/store/daemonset_test.go @@ -55,16 +55,16 @@ func TestDaemonSetStore(t *testing.T) { }, Want: ` # HELP kube_daemonset_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_daemonset_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_daemonset_metadata_generation Sequence number representing a specific generation of the desired state. - # HELP kube_daemonset_status_current_number_scheduled The number of nodes running at least one daemon pod and are supposed to. - # HELP kube_daemonset_status_desired_number_scheduled The number of nodes that should be running the daemon pod. - # HELP kube_daemonset_status_number_available The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available - # HELP kube_daemonset_status_number_misscheduled The number of nodes running a daemon pod but are not supposed to. - # HELP kube_daemonset_status_number_ready The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready. - # HELP kube_daemonset_status_number_unavailable The number of nodes that should be running the daemon pod and have none of the daemon pod running and available - # HELP kube_daemonset_status_observed_generation The most recent generation observed by the daemon set controller. - # HELP kube_daemonset_status_updated_number_scheduled The total number of nodes that are running updated daemon pod + # HELP kube_daemonset_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_daemonset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state. + # HELP kube_daemonset_status_current_number_scheduled [STABLE] The number of nodes running at least one daemon pod and are supposed to. + # HELP kube_daemonset_status_desired_number_scheduled [STABLE] The number of nodes that should be running the daemon pod. + # HELP kube_daemonset_status_number_available [STABLE] The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available + # HELP kube_daemonset_status_number_misscheduled [STABLE] The number of nodes running a daemon pod but are not supposed to. + # HELP kube_daemonset_status_number_ready [STABLE] The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready. + # HELP kube_daemonset_status_number_unavailable [STABLE] The number of nodes that should be running the daemon pod and have none of the daemon pod running and available + # HELP kube_daemonset_status_observed_generation [STABLE] The most recent generation observed by the daemon set controller. + # HELP kube_daemonset_status_updated_number_scheduled [STABLE] The total number of nodes that are running updated daemon pod # TYPE kube_daemonset_annotations gauge # TYPE kube_daemonset_labels gauge # TYPE kube_daemonset_metadata_generation gauge @@ -121,25 +121,25 @@ func TestDaemonSetStore(t *testing.T) { }, }, Want: ` - # HELP kube_daemonset_created Unix creation timestamp + # HELP kube_daemonset_created [STABLE] Unix creation timestamp # TYPE kube_daemonset_created gauge - # HELP kube_daemonset_status_current_number_scheduled The number of nodes running at least one daemon pod and are supposed to. + # HELP kube_daemonset_status_current_number_scheduled [STABLE] The number of nodes running at least one daemon pod and are supposed to. # TYPE kube_daemonset_status_current_number_scheduled gauge - # HELP kube_daemonset_status_desired_number_scheduled The number of nodes that should be running the daemon pod. + # HELP kube_daemonset_status_desired_number_scheduled [STABLE] The number of nodes that should be running the daemon pod. # TYPE kube_daemonset_status_desired_number_scheduled gauge - # HELP kube_daemonset_status_number_available The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available + # HELP kube_daemonset_status_number_available [STABLE] The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available # TYPE kube_daemonset_status_number_available gauge - # HELP kube_daemonset_status_number_misscheduled The number of nodes running a daemon pod but are not supposed to. + # HELP kube_daemonset_status_number_misscheduled [STABLE] The number of nodes running a daemon pod but are not supposed to. # TYPE kube_daemonset_status_number_misscheduled gauge - # HELP kube_daemonset_status_number_ready The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready. + # HELP kube_daemonset_status_number_ready [STABLE] The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready. # TYPE kube_daemonset_status_number_ready gauge - # HELP kube_daemonset_status_number_unavailable The number of nodes that should be running the daemon pod and have none of the daemon pod running and available + # HELP kube_daemonset_status_number_unavailable [STABLE] The number of nodes that should be running the daemon pod and have none of the daemon pod running and available # TYPE kube_daemonset_status_number_unavailable gauge - # HELP kube_daemonset_status_updated_number_scheduled The total number of nodes that are running updated daemon pod + # HELP kube_daemonset_status_updated_number_scheduled [STABLE] The total number of nodes that are running updated daemon pod # TYPE kube_daemonset_status_updated_number_scheduled gauge - # HELP kube_daemonset_metadata_generation Sequence number representing a specific generation of the desired state. + # HELP kube_daemonset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state. # TYPE kube_daemonset_metadata_generation gauge - # HELP kube_daemonset_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_daemonset_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_daemonset_labels gauge kube_daemonset_metadata_generation{daemonset="ds2",namespace="ns2"} 14 kube_daemonset_status_current_number_scheduled{daemonset="ds2",namespace="ns2"} 10 @@ -187,25 +187,25 @@ func TestDaemonSetStore(t *testing.T) { }, }, Want: ` - # HELP kube_daemonset_created Unix creation timestamp + # HELP kube_daemonset_created [STABLE] Unix creation timestamp # TYPE kube_daemonset_created gauge - # HELP kube_daemonset_status_current_number_scheduled The number of nodes running at least one daemon pod and are supposed to. + # HELP kube_daemonset_status_current_number_scheduled [STABLE] The number of nodes running at least one daemon pod and are supposed to. # TYPE kube_daemonset_status_current_number_scheduled gauge - # HELP kube_daemonset_status_desired_number_scheduled The number of nodes that should be running the daemon pod. + # HELP kube_daemonset_status_desired_number_scheduled [STABLE] The number of nodes that should be running the daemon pod. # TYPE kube_daemonset_status_desired_number_scheduled gauge - # HELP kube_daemonset_status_number_available The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available + # HELP kube_daemonset_status_number_available [STABLE] The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available # TYPE kube_daemonset_status_number_available gauge - # HELP kube_daemonset_status_number_misscheduled The number of nodes running a daemon pod but are not supposed to. + # HELP kube_daemonset_status_number_misscheduled [STABLE] The number of nodes running a daemon pod but are not supposed to. # TYPE kube_daemonset_status_number_misscheduled gauge - # HELP kube_daemonset_status_number_ready The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready. + # HELP kube_daemonset_status_number_ready [STABLE] The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready. # TYPE kube_daemonset_status_number_ready gauge - # HELP kube_daemonset_status_number_unavailable The number of nodes that should be running the daemon pod and have none of the daemon pod running and available + # HELP kube_daemonset_status_number_unavailable [STABLE] The number of nodes that should be running the daemon pod and have none of the daemon pod running and available # TYPE kube_daemonset_status_number_unavailable gauge - # HELP kube_daemonset_status_updated_number_scheduled The total number of nodes that are running updated daemon pod + # HELP kube_daemonset_status_updated_number_scheduled [STABLE] The total number of nodes that are running updated daemon pod # TYPE kube_daemonset_status_updated_number_scheduled gauge - # HELP kube_daemonset_metadata_generation Sequence number representing a specific generation of the desired state. + # HELP kube_daemonset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state. # TYPE kube_daemonset_metadata_generation gauge - # HELP kube_daemonset_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_daemonset_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_daemonset_labels gauge kube_daemonset_created{daemonset="ds3",namespace="ns3"} 1.5e+09 kube_daemonset_metadata_generation{daemonset="ds3",namespace="ns3"} 15 diff --git a/internal/store/deployment.go b/internal/store/deployment.go index fca897dca5..d20a2ffcb3 100644 --- a/internal/store/deployment.go +++ b/internal/store/deployment.go @@ -19,6 +19,8 @@ package store import ( "context" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -41,10 +43,11 @@ var ( func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { ms := []*metric.Metric{} @@ -60,10 +63,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_replicas", "The number of replicas per deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -75,10 +79,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_replicas_ready", "The number of ready replicas per deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -90,10 +95,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_replicas_available", "The number of available replicas per deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -105,10 +111,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_replicas_unavailable", "The number of unavailable replicas per deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -120,10 +127,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_replicas_updated", "The number of updated replicas per deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -135,10 +143,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_observed_generation", "The generation observed by the deployment controller.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -150,10 +159,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_status_condition", "The current status conditions of a deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { ms := make([]*metric.Metric, len(d.Status.Conditions)*len(conditionStatuses)) @@ -175,10 +185,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_spec_replicas", "Number of desired pods for a deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -190,10 +201,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_spec_paused", "Whether the deployment is paused and will not be processed by the deployment controller.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -205,10 +217,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_spec_strategy_rollingupdate_max_unavailable", "Maximum number of unavailable replicas during a rolling update of a deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { if d.Spec.Strategy.RollingUpdate == nil { @@ -229,10 +242,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_spec_strategy_rollingupdate_max_surge", "Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a deployment.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { if d.Spec.Strategy.RollingUpdate == nil { @@ -253,10 +267,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_deployment_metadata_generation", "Sequence number representing a specific generation of the desired state.", metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { return &metric.Family{ @@ -286,10 +301,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descDeploymentLabelsName, descDeploymentLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", d.Labels, allowLabelsList) diff --git a/internal/store/deployment_test.go b/internal/store/deployment_test.go index 093fc3cf6e..0223011e09 100644 --- a/internal/store/deployment_test.go +++ b/internal/store/deployment_test.go @@ -45,33 +45,33 @@ func TestDeploymentStore(t *testing.T) { const metadata = ` # HELP kube_deployment_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_deployment_annotations gauge - # HELP kube_deployment_created Unix creation timestamp + # HELP kube_deployment_created [STABLE] Unix creation timestamp # TYPE kube_deployment_created gauge - # HELP kube_deployment_metadata_generation Sequence number representing a specific generation of the desired state. + # HELP kube_deployment_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state. # TYPE kube_deployment_metadata_generation gauge - # HELP kube_deployment_spec_paused Whether the deployment is paused and will not be processed by the deployment controller. + # HELP kube_deployment_spec_paused [STABLE] Whether the deployment is paused and will not be processed by the deployment controller. # TYPE kube_deployment_spec_paused gauge - # HELP kube_deployment_spec_replicas Number of desired pods for a deployment. + # HELP kube_deployment_spec_replicas [STABLE] Number of desired pods for a deployment. # TYPE kube_deployment_spec_replicas gauge - # HELP kube_deployment_status_replicas The number of replicas per deployment. + # HELP kube_deployment_status_replicas [STABLE] The number of replicas per deployment. # TYPE kube_deployment_status_replicas gauge - # HELP kube_deployment_status_replicas_ready The number of ready replicas per deployment. + # HELP kube_deployment_status_replicas_ready [STABLE] The number of ready replicas per deployment. # TYPE kube_deployment_status_replicas_ready gauge - # HELP kube_deployment_status_replicas_available The number of available replicas per deployment. + # HELP kube_deployment_status_replicas_available [STABLE] The number of available replicas per deployment. # TYPE kube_deployment_status_replicas_available gauge - # HELP kube_deployment_status_replicas_unavailable The number of unavailable replicas per deployment. + # HELP kube_deployment_status_replicas_unavailable [STABLE] The number of unavailable replicas per deployment. # TYPE kube_deployment_status_replicas_unavailable gauge - # HELP kube_deployment_status_replicas_updated The number of updated replicas per deployment. + # HELP kube_deployment_status_replicas_updated [STABLE] The number of updated replicas per deployment. # TYPE kube_deployment_status_replicas_updated gauge - # HELP kube_deployment_status_observed_generation The generation observed by the deployment controller. + # HELP kube_deployment_status_observed_generation [STABLE] The generation observed by the deployment controller. # TYPE kube_deployment_status_observed_generation gauge - # HELP kube_deployment_status_condition The current status conditions of a deployment. + # HELP kube_deployment_status_condition [STABLE] The current status conditions of a deployment. # TYPE kube_deployment_status_condition gauge - # HELP kube_deployment_spec_strategy_rollingupdate_max_unavailable Maximum number of unavailable replicas during a rolling update of a deployment. + # HELP kube_deployment_spec_strategy_rollingupdate_max_unavailable [STABLE] Maximum number of unavailable replicas during a rolling update of a deployment. # TYPE kube_deployment_spec_strategy_rollingupdate_max_unavailable gauge - # HELP kube_deployment_spec_strategy_rollingupdate_max_surge Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a deployment. + # HELP kube_deployment_spec_strategy_rollingupdate_max_surge [STABLE] Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a deployment. # TYPE kube_deployment_spec_strategy_rollingupdate_max_surge gauge - # HELP kube_deployment_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_deployment_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_deployment_labels gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/endpoint.go b/internal/store/endpoint.go index 8a26477a15..1763392dba 100644 --- a/internal/store/endpoint.go +++ b/internal/store/endpoint.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -41,10 +42,11 @@ var ( func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_endpoint_info", "Information about endpoint.", metric.Gauge, + basemetrics.STABLE, "", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { return &metric.Family{ @@ -56,10 +58,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_endpoint_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} @@ -94,10 +97,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descEndpointLabelsName, descEndpointLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", e.Labels, allowLabelsList) @@ -151,10 +155,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_endpoint_address", "Information about Endpoint available and non available addresses.", metric.Gauge, + basemetrics.STABLE, "", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} @@ -179,10 +184,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_endpoint_ports", "Information about the Endpoint ports.", metric.Gauge, + basemetrics.STABLE, "", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/endpoint_test.go b/internal/store/endpoint_test.go index 3dfb49c818..46df12e7df 100644 --- a/internal/store/endpoint_test.go +++ b/internal/store/endpoint_test.go @@ -36,15 +36,15 @@ func TestEndpointStore(t *testing.T) { # TYPE kube_endpoint_address_available gauge # HELP kube_endpoint_address_not_ready (Deprecated since v2.6.0) Number of addresses not ready in endpoint # TYPE kube_endpoint_address_not_ready gauge - # HELP kube_endpoint_created Unix creation timestamp + # HELP kube_endpoint_created [STABLE] Unix creation timestamp # TYPE kube_endpoint_created gauge - # HELP kube_endpoint_info Information about endpoint. + # HELP kube_endpoint_info [STABLE] Information about endpoint. # TYPE kube_endpoint_info gauge - # HELP kube_endpoint_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_endpoint_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_endpoint_labels gauge - # HELP kube_endpoint_ports Information about the Endpoint ports. + # HELP kube_endpoint_ports [STABLE] Information about the Endpoint ports. # TYPE kube_endpoint_ports gauge - # HELP kube_endpoint_address Information about Endpoint available and non available addresses. + # HELP kube_endpoint_address [STABLE] Information about Endpoint available and non available addresses. # TYPE kube_endpoint_address gauge ` cases := []generateMetricsTestCase{ @@ -166,15 +166,15 @@ func TestEndpointStoreWithLabels(t *testing.T) { # TYPE kube_endpoint_address_not_ready gauge # HELP kube_endpoint_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_endpoint_annotations gauge - # HELP kube_endpoint_created Unix creation timestamp + # HELP kube_endpoint_created [STABLE] Unix creation timestamp # TYPE kube_endpoint_created gauge - # HELP kube_endpoint_info Information about endpoint. + # HELP kube_endpoint_info [STABLE] Information about endpoint. # TYPE kube_endpoint_info gauge - # HELP kube_endpoint_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_endpoint_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_endpoint_labels gauge - # HELP kube_endpoint_ports Information about the Endpoint ports. + # HELP kube_endpoint_ports [STABLE] Information about the Endpoint ports. # TYPE kube_endpoint_ports gauge - # HELP kube_endpoint_address Information about Endpoint available and non available addresses. + # HELP kube_endpoint_address [STABLE] Information about Endpoint available and non available addresses. # TYPE kube_endpoint_address gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/horizontalpodautoscaler.go b/internal/store/horizontalpodautoscaler.go index 1b0de5241a..05176811ea 100644 --- a/internal/store/horizontalpodautoscaler.go +++ b/internal/store/horizontalpodautoscaler.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -77,10 +78,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_horizontalpodautoscaler_metadata_generation", "The generation observed by the HorizontalPodAutoscaler controller.", metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { return &metric.Family{ @@ -92,10 +94,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_horizontalpodautoscaler_spec_max_replicas", "Upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas.", metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { return &metric.Family{ @@ -107,10 +110,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_horizontalpodautoscaler_spec_min_replicas", "Lower limit for the number of pods that can be set by the autoscaler, default 1.", metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { return &metric.Family{ @@ -246,10 +250,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat return &metric.Family{Metrics: ms} }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_horizontalpodautoscaler_status_current_replicas", "Current number of replicas of pods managed by this autoscaler.", metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { return &metric.Family{ @@ -261,10 +266,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_horizontalpodautoscaler_status_desired_replicas", "Desired number of replicas of pods managed by this autoscaler.", metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { return &metric.Family{ @@ -294,10 +300,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descHorizontalPodAutoscalerLabelsName, descHorizontalPodAutoscalerLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", a.Labels, allowLabelsList) @@ -312,10 +319,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_horizontalpodautoscaler_status_condition", "The condition of this autoscaler.", metric.Gauge, + basemetrics.STABLE, "", wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family { ms := make([]*metric.Metric, 0, len(a.Status.Conditions)*len(conditionStatuses)) diff --git a/internal/store/horizontalpodautoscaler_test.go b/internal/store/horizontalpodautoscaler_test.go index d573113a70..050b68fc9a 100644 --- a/internal/store/horizontalpodautoscaler_test.go +++ b/internal/store/horizontalpodautoscaler_test.go @@ -37,15 +37,15 @@ func TestHPAStore(t *testing.T) { const metadata = ` # HELP kube_horizontalpodautoscaler_info Information about this autoscaler. # HELP kube_horizontalpodautoscaler_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_horizontalpodautoscaler_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_horizontalpodautoscaler_metadata_generation The generation observed by the HorizontalPodAutoscaler controller. - # HELP kube_horizontalpodautoscaler_spec_max_replicas Upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas. - # HELP kube_horizontalpodautoscaler_spec_min_replicas Lower limit for the number of pods that can be set by the autoscaler, default 1. + # HELP kube_horizontalpodautoscaler_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_horizontalpodautoscaler_metadata_generation [STABLE] The generation observed by the HorizontalPodAutoscaler controller. + # HELP kube_horizontalpodautoscaler_spec_max_replicas [STABLE] Upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas. + # HELP kube_horizontalpodautoscaler_spec_min_replicas [STABLE] Lower limit for the number of pods that can be set by the autoscaler, default 1. # HELP kube_horizontalpodautoscaler_spec_target_metric The metric specifications used by this autoscaler when calculating the desired replica count. # HELP kube_horizontalpodautoscaler_status_target_metric The current metric status used by this autoscaler when calculating the desired replica count. - # HELP kube_horizontalpodautoscaler_status_condition The condition of this autoscaler. - # HELP kube_horizontalpodautoscaler_status_current_replicas Current number of replicas of pods managed by this autoscaler. - # HELP kube_horizontalpodautoscaler_status_desired_replicas Desired number of replicas of pods managed by this autoscaler. + # HELP kube_horizontalpodautoscaler_status_condition [STABLE] The condition of this autoscaler. + # HELP kube_horizontalpodautoscaler_status_current_replicas [STABLE] Current number of replicas of pods managed by this autoscaler. + # HELP kube_horizontalpodautoscaler_status_desired_replicas [STABLE] Desired number of replicas of pods managed by this autoscaler. # TYPE kube_horizontalpodautoscaler_info gauge # TYPE kube_horizontalpodautoscaler_annotations gauge # TYPE kube_horizontalpodautoscaler_labels gauge diff --git a/internal/store/ingress.go b/internal/store/ingress.go index 233ff90aeb..9136fecf6c 100644 --- a/internal/store/ingress.go +++ b/internal/store/ingress.go @@ -20,6 +20,8 @@ import ( "context" "strconv" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -41,10 +43,11 @@ var ( func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_ingress_info", "Information about ingress.", metric.Gauge, + basemetrics.STABLE, "", wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family { ingressClassName := "_default" @@ -83,10 +86,11 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descIngressLabelsName, descIngressLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", i.Labels, allowLabelsList) @@ -101,10 +105,11 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_ingress_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family { ms := []*metric.Metric{} @@ -131,10 +136,11 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_ingress_path", "Ingress host, paths and backend service information.", metric.Gauge, + basemetrics.STABLE, "", wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family { ms := []*metric.Metric{} @@ -162,10 +168,11 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_ingress_tls", "Ingress TLS host and secret information.", metric.Gauge, + basemetrics.STABLE, "", wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/ingress_test.go b/internal/store/ingress_test.go index 9064e35c27..123a679cbd 100644 --- a/internal/store/ingress_test.go +++ b/internal/store/ingress_test.go @@ -34,12 +34,12 @@ func TestIngressStore(t *testing.T) { // Fixed metadata on type and help text. We prepend this to every expected // output so we only have to modify a single place when doing adjustments. const metadata = ` - # HELP kube_ingress_created Unix creation timestamp - # HELP kube_ingress_info Information about ingress. - # HELP kube_ingress_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_ingress_created [STABLE] Unix creation timestamp + # HELP kube_ingress_info [STABLE] Information about ingress. + # HELP kube_ingress_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_ingress_metadata_resource_version Resource version representing a specific version of ingress. - # HELP kube_ingress_path Ingress host, paths and backend service information. - # HELP kube_ingress_tls Ingress TLS host and secret information. + # HELP kube_ingress_path [STABLE] Ingress host, paths and backend service information. + # HELP kube_ingress_tls [STABLE] Ingress TLS host and secret information. # TYPE kube_ingress_created gauge # TYPE kube_ingress_info gauge # TYPE kube_ingress_labels gauge @@ -64,9 +64,9 @@ func TestIngressStore(t *testing.T) { }, }, Want: ` - # HELP kube_ingress_info Information about ingress. + # HELP kube_ingress_info [STABLE] Information about ingress. # HELP kube_ingress_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_ingress_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_ingress_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_ingress_metadata_resource_version Resource version representing a specific version of ingress. # TYPE kube_ingress_info gauge # TYPE kube_ingress_annotations gauge diff --git a/internal/store/job.go b/internal/store/job.go index e2664310e6..cd878c7e08 100644 --- a/internal/store/job.go +++ b/internal/store/job.go @@ -20,6 +20,8 @@ import ( "context" "strconv" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -60,10 +62,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descJobLabelsName, descJobLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList) @@ -78,10 +81,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_info", "Information about job.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { return &metric.Family{ @@ -93,10 +97,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -112,10 +117,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_spec_parallelism", "The maximum desired number of pods the job should run at any given time.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -131,10 +137,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_spec_completions", "The desired number of successfully finished pods the job should be run with.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -150,10 +157,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_spec_active_deadline_seconds", "The duration in seconds relative to the startTime that the job may be active before the system tries to terminate it.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -169,10 +177,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_status_succeeded", "The number of pods which reached Phase Succeeded.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { return &metric.Family{ @@ -184,10 +193,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_status_failed", "The number of pods which reached Phase Failed and the reason for failure.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { var ms []*metric.Metric @@ -231,10 +241,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_status_active", "The number of actively running pods.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { return &metric.Family{ @@ -246,10 +257,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_complete", "The job has completed its execution.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -269,10 +281,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_failed", "The job has failed its execution.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -293,10 +306,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_status_start_time", "StartTime represents time when the job was acknowledged by the Job Manager.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -313,10 +327,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_status_completion_time", "CompletionTime represents time when the job was completed.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { ms := []*metric.Metric{} @@ -332,10 +347,11 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_job_owner", "Information about the Job's owner.", metric.Gauge, + basemetrics.STABLE, "", wrapJobFunc(func(j *v1batch.Job) *metric.Family { labelKeys := []string{"owner_kind", "owner_name", "owner_is_controller"} diff --git a/internal/store/job_test.go b/internal/store/job_test.go index 3cfb68ef70..3cb2b13174 100644 --- a/internal/store/job_test.go +++ b/internal/store/job_test.go @@ -50,33 +50,33 @@ func TestJobStore(t *testing.T) { const metadata = ` # HELP kube_job_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_job_annotations gauge - # HELP kube_job_created Unix creation timestamp + # HELP kube_job_created [STABLE] Unix creation timestamp # TYPE kube_job_created gauge - # HELP kube_job_owner Information about the Job's owner. + # HELP kube_job_owner [STABLE] Information about the Job's owner. # TYPE kube_job_owner gauge - # HELP kube_job_complete The job has completed its execution. + # HELP kube_job_complete [STABLE] The job has completed its execution. # TYPE kube_job_complete gauge - # HELP kube_job_failed The job has failed its execution. + # HELP kube_job_failed [STABLE] The job has failed its execution. # TYPE kube_job_failed gauge - # HELP kube_job_info Information about job. + # HELP kube_job_info [STABLE] Information about job. # TYPE kube_job_info gauge - # HELP kube_job_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_job_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_job_labels gauge - # HELP kube_job_spec_active_deadline_seconds The duration in seconds relative to the startTime that the job may be active before the system tries to terminate it. + # HELP kube_job_spec_active_deadline_seconds [STABLE] The duration in seconds relative to the startTime that the job may be active before the system tries to terminate it. # TYPE kube_job_spec_active_deadline_seconds gauge - # HELP kube_job_spec_completions The desired number of successfully finished pods the job should be run with. + # HELP kube_job_spec_completions [STABLE] The desired number of successfully finished pods the job should be run with. # TYPE kube_job_spec_completions gauge - # HELP kube_job_spec_parallelism The maximum desired number of pods the job should run at any given time. + # HELP kube_job_spec_parallelism [STABLE] The maximum desired number of pods the job should run at any given time. # TYPE kube_job_spec_parallelism gauge - # HELP kube_job_status_active The number of actively running pods. + # HELP kube_job_status_active [STABLE] The number of actively running pods. # TYPE kube_job_status_active gauge - # HELP kube_job_status_completion_time CompletionTime represents time when the job was completed. + # HELP kube_job_status_completion_time [STABLE] CompletionTime represents time when the job was completed. # TYPE kube_job_status_completion_time gauge - # HELP kube_job_status_failed The number of pods which reached Phase Failed and the reason for failure. + # HELP kube_job_status_failed [STABLE] The number of pods which reached Phase Failed and the reason for failure. # TYPE kube_job_status_failed gauge - # HELP kube_job_status_start_time StartTime represents time when the job was acknowledged by the Job Manager. + # HELP kube_job_status_start_time [STABLE] StartTime represents time when the job was acknowledged by the Job Manager. # TYPE kube_job_status_start_time gauge - # HELP kube_job_status_succeeded The number of pods which reached Phase Succeeded. + # HELP kube_job_status_succeeded [STABLE] The number of pods which reached Phase Succeeded. # TYPE kube_job_status_succeeded gauge` cases := []generateMetricsTestCase{ diff --git a/internal/store/limitrange.go b/internal/store/limitrange.go index 1163a2de1a..ef1bd8ffa4 100644 --- a/internal/store/limitrange.go +++ b/internal/store/limitrange.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -34,10 +35,11 @@ var ( descLimitRangeLabelsDefaultLabels = []string{"namespace", "limitrange"} limitRangeMetricFamilies = []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_limitrange", "Information about limit range.", metric.Gauge, + basemetrics.STABLE, "", wrapLimitRangeFunc(func(r *v1.LimitRange) *metric.Family { ms := []*metric.Metric{} @@ -89,10 +91,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_limitrange_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapLimitRangeFunc(func(r *v1.LimitRange) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/limitrange_test.go b/internal/store/limitrange_test.go index 22f531bc26..76741e3e16 100644 --- a/internal/store/limitrange_test.go +++ b/internal/store/limitrange_test.go @@ -33,9 +33,9 @@ func TestLimitRangeStore(t *testing.T) { // Fixed metadata on type and help text. We prepend this to every expected // output so we only have to modify a single place when doing adjustments. const metadata = ` - # HELP kube_limitrange_created Unix creation timestamp + # HELP kube_limitrange_created [STABLE] Unix creation timestamp # TYPE kube_limitrange_created gauge - # HELP kube_limitrange Information about limit range. + # HELP kube_limitrange [STABLE] Information about limit range. # TYPE kube_limitrange gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/namespace.go b/internal/store/namespace.go index 40a45b2461..81d0a53dfa 100644 --- a/internal/store/namespace.go +++ b/internal/store/namespace.go @@ -19,6 +19,8 @@ package store import ( "context" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +42,11 @@ var ( func namespaceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_namespace_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family { ms := []*metric.Metric{} @@ -76,10 +79,11 @@ func namespaceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descNamespaceLabelsName, descNamespaceLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", n.Labels, allowLabelsList) @@ -94,10 +98,11 @@ func namespaceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_namespace_status_phase", "kubernetes namespace status phase.", metric.Gauge, + basemetrics.STABLE, "", wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family { ms := []*metric.Metric{ diff --git a/internal/store/namespace_test.go b/internal/store/namespace_test.go index f550ed0e1e..2f8161f094 100644 --- a/internal/store/namespace_test.go +++ b/internal/store/namespace_test.go @@ -32,11 +32,11 @@ func TestNamespaceStore(t *testing.T) { const metadata = ` # HELP kube_namespace_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_namespace_annotations gauge - # HELP kube_namespace_created Unix creation timestamp + # HELP kube_namespace_created [STABLE] Unix creation timestamp # TYPE kube_namespace_created gauge - # HELP kube_namespace_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_namespace_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_namespace_labels gauge - # HELP kube_namespace_status_phase kubernetes namespace status phase. + # HELP kube_namespace_status_phase [STABLE] kubernetes namespace status phase. # TYPE kube_namespace_status_phase gauge # HELP kube_namespace_status_condition The condition of a namespace. # TYPE kube_namespace_status_condition gauge diff --git a/internal/store/node.go b/internal/store/node.go index ae464acb5b..09ec39140c 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -20,6 +20,8 @@ import ( "context" "strings" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/constant" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -56,10 +58,11 @@ func nodeMetricFamilies(allowAnnotationsList, allowLabelsList []string) []genera } func createNodeCreatedFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { ms := []*metric.Metric{} @@ -79,10 +82,11 @@ func createNodeCreatedFamilyGenerator() generator.FamilyGenerator { } func createNodeInfoFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_info", "Information about a cluster node.", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { labelKeys := []string{ @@ -150,10 +154,11 @@ func createNodeAnnotationsGenerator(allowAnnotationsList []string) generator.Fam } func createNodeLabelsGenerator(allowLabelsList []string) generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( descNodeLabelsName, descNodeLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", n.Labels, allowLabelsList) @@ -196,10 +201,11 @@ func createNodeRoleFamilyGenerator() generator.FamilyGenerator { } func createNodeSpecTaintFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_spec_taint", "The taint of a cluster node.", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { ms := make([]*metric.Metric, len(n.Spec.Taints)) @@ -223,10 +229,11 @@ func createNodeSpecTaintFamilyGenerator() generator.FamilyGenerator { } func createNodeSpecUnschedulableFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_spec_unschedulable", "Whether a node can schedule new pods.", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { return &metric.Family{ @@ -241,10 +248,11 @@ func createNodeSpecUnschedulableFamilyGenerator() generator.FamilyGenerator { } func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_status_allocatable", "The allocatable for different resources of a node that are available for scheduling.", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { ms := []*metric.Metric{} @@ -324,10 +332,11 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { } func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_status_capacity", "The capacity for different resources of a node.", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { ms := []*metric.Metric{} @@ -410,10 +419,11 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { // customized condition for cluster node (e.g. node-problem-detector), and // Kubernetes may add new core conditions in future. func createNodeStatusConditionFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_node_status_condition", "The condition of a cluster node.", metric.Gauge, + basemetrics.STABLE, "", wrapNodeFunc(func(n *v1.Node) *metric.Family { ms := make([]*metric.Metric, len(n.Status.Conditions)*len(conditionStatuses)) diff --git a/internal/store/node_test.go b/internal/store/node_test.go index 2490720d15..0e44431705 100644 --- a/internal/store/node_test.go +++ b/internal/store/node_test.go @@ -54,9 +54,9 @@ func TestNodeStore(t *testing.T) { }, }, Want: ` - # HELP kube_node_info Information about a cluster node. - # HELP kube_node_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_node_spec_unschedulable Whether a node can schedule new pods. + # HELP kube_node_info [STABLE] Information about a cluster node. + # HELP kube_node_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_node_spec_unschedulable [STABLE] Whether a node can schedule new pods. # TYPE kube_node_info gauge # TYPE kube_node_labels gauge # TYPE kube_node_spec_unschedulable gauge @@ -74,7 +74,7 @@ func TestNodeStore(t *testing.T) { Spec: v1.NodeSpec{}, }, Want: ` - # HELP kube_node_info Information about a cluster node. + # HELP kube_node_info [STABLE] Information about a cluster node. # TYPE kube_node_info gauge kube_node_info{container_runtime_version="",kernel_version="",kubelet_version="",kubeproxy_version="",node="",os_image="",pod_cidr="",provider_id="",internal_ip="",system_uuid=""} 1 `, @@ -126,13 +126,13 @@ func TestNodeStore(t *testing.T) { }, }, Want: ` - # HELP kube_node_created Unix creation timestamp - # HELP kube_node_info Information about a cluster node. - # HELP kube_node_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_node_created [STABLE] Unix creation timestamp + # HELP kube_node_info [STABLE] Information about a cluster node. + # HELP kube_node_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_node_role The role of a cluster node. - # HELP kube_node_spec_unschedulable Whether a node can schedule new pods. - # HELP kube_node_status_allocatable The allocatable for different resources of a node that are available for scheduling. - # HELP kube_node_status_capacity The capacity for different resources of a node. + # HELP kube_node_spec_unschedulable [STABLE] Whether a node can schedule new pods. + # HELP kube_node_status_allocatable [STABLE] The allocatable for different resources of a node that are available for scheduling. + # HELP kube_node_status_capacity [STABLE] The capacity for different resources of a node. # TYPE kube_node_created gauge # TYPE kube_node_info gauge # TYPE kube_node_labels gauge @@ -183,7 +183,7 @@ func TestNodeStore(t *testing.T) { }, }, Want: ` - # HELP kube_node_status_condition The condition of a cluster node. + # HELP kube_node_status_condition [STABLE] The condition of a cluster node. # TYPE kube_node_status_condition gauge kube_node_status_condition{condition="CustomizedType",node="127.0.0.1",status="false"} 0 kube_node_status_condition{condition="CustomizedType",node="127.0.0.1",status="true"} 1 @@ -211,7 +211,7 @@ func TestNodeStore(t *testing.T) { }, }, Want: ` - # HELP kube_node_status_condition The condition of a cluster node. + # HELP kube_node_status_condition [STABLE] The condition of a cluster node. # TYPE kube_node_status_condition gauge kube_node_status_condition{condition="CustomizedType",node="127.0.0.2",status="false"} 0 kube_node_status_condition{condition="CustomizedType",node="127.0.0.2",status="true"} 0 @@ -239,7 +239,7 @@ func TestNodeStore(t *testing.T) { }, }, Want: ` - # HELP kube_node_status_condition The condition of a cluster node. + # HELP kube_node_status_condition [STABLE] The condition of a cluster node. # TYPE kube_node_status_condition gauge kube_node_status_condition{condition="CustomizedType",node="127.0.0.3",status="false"} 1 kube_node_status_condition{condition="CustomizedType",node="127.0.0.3",status="true"} 0 @@ -268,7 +268,7 @@ func TestNodeStore(t *testing.T) { }, }, Want: ` - # HELP kube_node_spec_taint The taint of a cluster node. + # HELP kube_node_spec_taint [STABLE] The taint of a cluster node. # TYPE kube_node_spec_taint gauge kube_node_spec_taint{effect="PreferNoSchedule",key="Dedicated",node="127.0.0.1",value=""} 1 kube_node_spec_taint{effect="PreferNoSchedule",key="Accelerated",node="127.0.0.1",value="gpu"} 1 diff --git a/internal/store/persistentvolume.go b/internal/store/persistentvolume.go index 8354d0972e..7955d913bb 100644 --- a/internal/store/persistentvolume.go +++ b/internal/store/persistentvolume.go @@ -20,6 +20,8 @@ import ( "context" "strconv" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -45,10 +47,11 @@ var ( func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descPersistentVolumeClaimRefName, descPersistentVolumeClaimRefHelp, metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { claimRef := p.Spec.ClaimRef @@ -93,10 +96,11 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descPersistentVolumeLabelsName, descPersistentVolumeLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", p.Labels, allowLabelsList) @@ -111,10 +115,11 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolume_status_phase", "The phase indicates if a volume is available, bound to a claim, or released by a claim.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { phase := p.Status.Phase @@ -158,10 +163,11 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolume_info", "Information about persistentvolume.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { var ( @@ -275,10 +281,11 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolume_capacity_bytes", "Persistentvolume capacity in bytes.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { storage := p.Spec.Capacity[v1.ResourceStorage] diff --git a/internal/store/persistentvolume_test.go b/internal/store/persistentvolume_test.go index 87ee21f665..a5686d1d3c 100644 --- a/internal/store/persistentvolume_test.go +++ b/internal/store/persistentvolume_test.go @@ -42,7 +42,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_status_phase The phase indicates if a volume is available, bound to a claim, or released by a claim. + # HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim, or released by a claim. # TYPE kube_persistentvolume_status_phase gauge kube_persistentvolume_status_phase{persistentvolume="test-pv-pending",phase="Available"} 0 kube_persistentvolume_status_phase{persistentvolume="test-pv-pending",phase="Bound"} 0 @@ -64,7 +64,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_status_phase The phase indicates if a volume is available, bound to a claim, or released by a claim. + # HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim, or released by a claim. # TYPE kube_persistentvolume_status_phase gauge kube_persistentvolume_status_phase{persistentvolume="test-pv-available",phase="Available"} 1 kube_persistentvolume_status_phase{persistentvolume="test-pv-available",phase="Bound"} 0 @@ -84,7 +84,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_status_phase The phase indicates if a volume is available, bound to a claim, or released by a claim. + # HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim, or released by a claim. # TYPE kube_persistentvolume_status_phase gauge kube_persistentvolume_status_phase{persistentvolume="test-pv-bound",phase="Available"} 0 kube_persistentvolume_status_phase{persistentvolume="test-pv-bound",phase="Bound"} 1 @@ -104,7 +104,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_status_phase The phase indicates if a volume is available, bound to a claim, or released by a claim. + # HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim, or released by a claim. # TYPE kube_persistentvolume_status_phase gauge kube_persistentvolume_status_phase{persistentvolume="test-pv-released",phase="Available"} 0 kube_persistentvolume_status_phase{persistentvolume="test-pv-released",phase="Bound"} 0 @@ -125,7 +125,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_status_phase The phase indicates if a volume is available, bound to a claim, or released by a claim. + # HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim, or released by a claim. # TYPE kube_persistentvolume_status_phase gauge kube_persistentvolume_status_phase{persistentvolume="test-pv-failed",phase="Available"} 0 kube_persistentvolume_status_phase{persistentvolume="test-pv-failed",phase="Bound"} 0 @@ -148,7 +148,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_status_phase The phase indicates if a volume is available, bound to a claim, or released by a claim. + # HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim, or released by a claim. # TYPE kube_persistentvolume_status_phase gauge kube_persistentvolume_status_phase{persistentvolume="test-pv-pending",phase="Available"} 0 kube_persistentvolume_status_phase{persistentvolume="test-pv-pending",phase="Bound"} 0 @@ -170,7 +170,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -189,7 +189,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -212,7 +212,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="name",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -235,7 +235,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="aws://eu-west-1c/vol-012d34d567890123b",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -258,7 +258,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="azure_disk_1",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -282,7 +282,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="123",fc_target_wwns="0123456789abcdef,abcdef0123456789",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -305,7 +305,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="0123456789abcdef,abcdef0123456789",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -330,7 +330,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="iqn.my.test.server.target00",iscsi_lun="123",iscsi_target_portal="1.2.3.4:3260",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -356,7 +356,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="iqn.my.test.initiator:112233",iscsi_iqn="iqn.my.test.server.target00",iscsi_lun="123",iscsi_target_portal="1.2.3.4:3260",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -380,7 +380,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="/myPath",nfs_server="1.2.3.4",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -404,7 +404,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="test-driver",csi_volume_handle="test-volume-handle",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -428,7 +428,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="/mnt/data",local_fs="ext4",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -451,7 +451,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="/mnt/data",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -475,7 +475,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="/mnt/data",host_path_type="Directory",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -498,7 +498,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_info Information about persistentvolume. + # HELP kube_persistentvolume_info [STABLE] Information about persistentvolume. # TYPE kube_persistentvolume_info gauge kube_persistentvolume_info{azure_disk_name="",ebs_volume_id="",fc_lun="",fc_target_wwns="",fc_wwids="",gce_persistent_disk_name="",host_path="/mnt/data",host_path_type="",iscsi_initiator_name="",iscsi_iqn="",iscsi_lun="",iscsi_target_portal="",local_path="",local_fs="",nfs_path="",nfs_server="",csi_driver="",csi_volume_handle="",persistentvolume="test-pv-available",storageclass=""} 1 `, @@ -520,7 +520,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolume_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_persistentvolume_labels gauge kube_persistentvolume_labels{persistentvolume="test-labeled-pv"} 1 `, @@ -536,7 +536,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolume_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_persistentvolume_labels gauge kube_persistentvolume_labels{persistentvolume="test-unlabeled-pv"} 1 `, @@ -561,7 +561,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_claim_ref Information about the Persistent Volume Claim Reference. + # HELP kube_persistentvolume_claim_ref [STABLE] Information about the Persistent Volume Claim Reference. # TYPE kube_persistentvolume_claim_ref gauge kube_persistentvolume_claim_ref{claim_namespace="default",name="pv-claim",persistentvolume="test-claimed-pv"} 1 `, @@ -577,7 +577,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_claim_ref Information about the Persistent Volume Claim Reference. + # HELP kube_persistentvolume_claim_ref [STABLE] Information about the Persistent Volume Claim Reference. # TYPE kube_persistentvolume_claim_ref gauge `, MetricNames: []string{"kube_persistentvolume_claim_ref"}, @@ -594,7 +594,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_capacity_bytes Persistentvolume capacity in bytes. + # HELP kube_persistentvolume_capacity_bytes [STABLE] Persistentvolume capacity in bytes. # TYPE kube_persistentvolume_capacity_bytes gauge kube_persistentvolume_capacity_bytes{persistentvolume="test-pv"} 5.36870912e+09 `, @@ -625,7 +625,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, Want: ` # HELP kube_persistentvolume_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_persistentvolume_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolume_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_persistentvolume_annotations gauge # TYPE kube_persistentvolume_labels gauge kube_persistentvolume_annotations{annotation_app_k8s_io_owner="mysql-server",persistentvolume="test-allowlisted-labels-annotations"} 1 @@ -655,7 +655,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, Want: ` # HELP kube_persistentvolume_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_persistentvolume_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolume_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_persistentvolume_annotations gauge # TYPE kube_persistentvolume_labels gauge kube_persistentvolume_annotations{persistentvolume="test-defaul-labels-annotations"} 1 diff --git a/internal/store/persistentvolumeclaim.go b/internal/store/persistentvolumeclaim.go index 3d77901e39..b048faa674 100644 --- a/internal/store/persistentvolumeclaim.go +++ b/internal/store/persistentvolumeclaim.go @@ -19,6 +19,8 @@ package store import ( "context" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +42,11 @@ var ( func persistentVolumeClaimMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descPersistentVolumeClaimLabelsName, descPersistentVolumeClaimLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeClaimFunc(func(p *v1.PersistentVolumeClaim) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", p.Labels, allowLabelsList) @@ -76,10 +79,11 @@ func persistentVolumeClaimMetricFamilies(allowAnnotationsList, allowLabelsList [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolumeclaim_info", "Information about persistent volume claim.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeClaimFunc(func(p *v1.PersistentVolumeClaim) *metric.Family { storageClassName := getPersistentVolumeClaimClass(p) @@ -95,10 +99,11 @@ func persistentVolumeClaimMetricFamilies(allowAnnotationsList, allowLabelsList [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolumeclaim_status_phase", "The phase the persistent volume claim is currently in.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeClaimFunc(func(p *v1.PersistentVolumeClaim) *metric.Family { phase := p.Status.Phase @@ -134,10 +139,11 @@ func persistentVolumeClaimMetricFamilies(allowAnnotationsList, allowLabelsList [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolumeclaim_resource_requests_storage_bytes", "The capacity of storage requested by the persistent volume claim.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeClaimFunc(func(p *v1.PersistentVolumeClaim) *metric.Family { ms := []*metric.Metric{} @@ -153,10 +159,11 @@ func persistentVolumeClaimMetricFamilies(allowAnnotationsList, allowLabelsList [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_persistentvolumeclaim_access_mode", "The access mode(s) specified by the persistent volume claim.", metric.Gauge, + basemetrics.STABLE, "", wrapPersistentVolumeClaimFunc(func(p *v1.PersistentVolumeClaim) *metric.Family { ms := make([]*metric.Metric, len(p.Spec.AccessModes)) diff --git a/internal/store/persistentvolumeclaim_test.go b/internal/store/persistentvolumeclaim_test.go index 53be9bd5a5..4902dfe217 100644 --- a/internal/store/persistentvolumeclaim_test.go +++ b/internal/store/persistentvolumeclaim_test.go @@ -68,12 +68,12 @@ func TestPersistentVolumeClaimStore(t *testing.T) { }, Want: ` # HELP kube_persistentvolumeclaim_created Unix creation timestamp - # HELP kube_persistentvolumeclaim_access_mode The access mode(s) specified by the persistent volume claim. + # HELP kube_persistentvolumeclaim_access_mode [STABLE] The access mode(s) specified by the persistent volume claim. # HELP kube_persistentvolumeclaim_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_info Information about persistent volume claim. - # HELP kube_persistentvolumeclaim_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes The capacity of storage requested by the persistent volume claim. - # HELP kube_persistentvolumeclaim_status_phase The phase the persistent volume claim is currently in. + # HELP kube_persistentvolumeclaim_info [STABLE] Information about persistent volume claim. + # HELP kube_persistentvolumeclaim_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes [STABLE] The capacity of storage requested by the persistent volume claim. + # HELP kube_persistentvolumeclaim_status_phase [STABLE] The phase the persistent volume claim is currently in. # HELP kube_persistentvolumeclaim_status_condition Information about status of different conditions of persistent volume claim. # TYPE kube_persistentvolumeclaim_created gauge # TYPE kube_persistentvolumeclaim_access_mode gauge @@ -140,12 +140,12 @@ func TestPersistentVolumeClaimStore(t *testing.T) { }, Want: ` # HELP kube_persistentvolumeclaim_created Unix creation timestamp - # HELP kube_persistentvolumeclaim_access_mode The access mode(s) specified by the persistent volume claim. + # HELP kube_persistentvolumeclaim_access_mode [STABLE] The access mode(s) specified by the persistent volume claim. # HELP kube_persistentvolumeclaim_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_info Information about persistent volume claim. - # HELP kube_persistentvolumeclaim_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes The capacity of storage requested by the persistent volume claim. - # HELP kube_persistentvolumeclaim_status_phase The phase the persistent volume claim is currently in. + # HELP kube_persistentvolumeclaim_info [STABLE] Information about persistent volume claim. + # HELP kube_persistentvolumeclaim_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes [STABLE] The capacity of storage requested by the persistent volume claim. + # HELP kube_persistentvolumeclaim_status_phase [STABLE] The phase the persistent volume claim is currently in. # HELP kube_persistentvolumeclaim_status_condition Information about status of different conditions of persistent volume claim. # TYPE kube_persistentvolumeclaim_created gauge # TYPE kube_persistentvolumeclaim_access_mode gauge @@ -196,11 +196,11 @@ func TestPersistentVolumeClaimStore(t *testing.T) { }, Want: ` # HELP kube_persistentvolumeclaim_created Unix creation timestamp - # HELP kube_persistentvolumeclaim_access_mode The access mode(s) specified by the persistent volume claim. - # HELP kube_persistentvolumeclaim_info Information about persistent volume claim. - # HELP kube_persistentvolumeclaim_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes The capacity of storage requested by the persistent volume claim. - # HELP kube_persistentvolumeclaim_status_phase The phase the persistent volume claim is currently in. + # HELP kube_persistentvolumeclaim_access_mode [STABLE] The access mode(s) specified by the persistent volume claim. + # HELP kube_persistentvolumeclaim_info [STABLE] Information about persistent volume claim. + # HELP kube_persistentvolumeclaim_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes [STABLE] The capacity of storage requested by the persistent volume claim. + # HELP kube_persistentvolumeclaim_status_phase [STABLE] The phase the persistent volume claim is currently in. # HELP kube_persistentvolumeclaim_status_condition Information about status of different conditions of persistent volume claim. # TYPE kube_persistentvolumeclaim_created gauge # TYPE kube_persistentvolumeclaim_access_mode gauge @@ -241,12 +241,12 @@ func TestPersistentVolumeClaimStore(t *testing.T) { }, Want: ` # HELP kube_persistentvolumeclaim_created Unix creation timestamp - # HELP kube_persistentvolumeclaim_access_mode The access mode(s) specified by the persistent volume claim. + # HELP kube_persistentvolumeclaim_access_mode [STABLE] The access mode(s) specified by the persistent volume claim. # HELP kube_persistentvolumeclaim_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_info Information about persistent volume claim. - # HELP kube_persistentvolumeclaim_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes The capacity of storage requested by the persistent volume claim. - # HELP kube_persistentvolumeclaim_status_phase The phase the persistent volume claim is currently in. + # HELP kube_persistentvolumeclaim_info [STABLE] Information about persistent volume claim. + # HELP kube_persistentvolumeclaim_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_persistentvolumeclaim_resource_requests_storage_bytes [STABLE] The capacity of storage requested by the persistent volume claim. + # HELP kube_persistentvolumeclaim_status_phase [STABLE] The phase the persistent volume claim is currently in. # HELP kube_persistentvolumeclaim_status_condition Information about status of different conditions of persistent volume claim. # TYPE kube_persistentvolumeclaim_created gauge # TYPE kube_persistentvolumeclaim_access_mode gauge diff --git a/internal/store/pod.go b/internal/store/pod.go index 774fabaa00..3d09fc137c 100644 --- a/internal/store/pod.go +++ b/internal/store/pod.go @@ -20,6 +20,7 @@ import ( "context" "strconv" + basemetrics "k8s.io/component-base/metrics" "k8s.io/utils/net" "k8s.io/kube-state-metrics/v2/pkg/constant" @@ -92,10 +93,11 @@ func podMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } func createPodCompletionTimeFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_completion_time", "Completion time in unix timestamp for a pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -126,10 +128,11 @@ func createPodCompletionTimeFamilyGenerator() generator.FamilyGenerator { } func createPodContainerInfoFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_info", "Information about a container in a pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -280,10 +283,11 @@ func createPodContainerResourceRequestsFamilyGenerator() generator.FamilyGenerat } func createPodContainerStateStartedFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_state_started", "Start time in unix timestamp for a pod container.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -362,10 +366,11 @@ func createPodContainerStatusLastTerminatedExitCodeFamilyGenerator() generator.F } func createPodContainerStatusReadyFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_status_ready", "Describes whether the containers readiness check succeeded.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.ContainerStatuses)) @@ -385,10 +390,10 @@ func createPodContainerStatusReadyFamilyGenerator() generator.FamilyGenerator { } func createPodContainerStatusRestartsTotalFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_status_restarts_total", "The number of container restarts per container.", - metric.Counter, + metric.Counter, basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.ContainerStatuses)) @@ -409,10 +414,11 @@ func createPodContainerStatusRestartsTotalFamilyGenerator() generator.FamilyGene } func createPodContainerStatusRunningFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_status_running", "Describes whether the container is currently in running state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.ContainerStatuses)) @@ -433,10 +439,11 @@ func createPodContainerStatusRunningFamilyGenerator() generator.FamilyGenerator } func createPodContainerStatusTerminatedFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_status_terminated", "Describes whether the container is currently in terminated state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.ContainerStatuses)) @@ -482,10 +489,11 @@ func createPodContainerStatusTerminatedReasonFamilyGenerator() generator.FamilyG } func createPodContainerStatusWaitingFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_status_waiting", "Describes whether the container is currently in waiting state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.ContainerStatuses)) @@ -506,10 +514,11 @@ func createPodContainerStatusWaitingFamilyGenerator() generator.FamilyGenerator } func createPodContainerStatusWaitingReasonFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_container_status_waiting_reason", "Describes the reason the container is currently in waiting state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, 0, len(p.Status.ContainerStatuses)) @@ -531,10 +540,11 @@ func createPodContainerStatusWaitingReasonFamilyGenerator() generator.FamilyGene } func createPodCreatedFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -579,10 +589,11 @@ func createPodDeletionTimestampFamilyGenerator() generator.FamilyGenerator { } func createPodInfoFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_info", "Information about pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { createdBy := metav1.GetControllerOf(p) @@ -645,10 +656,11 @@ func createPodIPFamilyGenerator() generator.FamilyGenerator { } func createPodInitContainerInfoFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_init_container_info", "Information about an init container in a pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -824,10 +836,11 @@ func createPodInitContainerStatusLastTerminatedReasonFamilyGenerator() generator } func createPodInitContainerStatusReadyFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_init_container_status_ready", "Describes whether the init containers readiness check succeeded.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.InitContainerStatuses)) @@ -848,10 +861,10 @@ func createPodInitContainerStatusReadyFamilyGenerator() generator.FamilyGenerato } func createPodInitContainerStatusRestartsTotalFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_init_container_status_restarts_total", "The number of restarts for the init container.", - metric.Counter, + metric.Counter, basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.InitContainerStatuses)) @@ -872,10 +885,11 @@ func createPodInitContainerStatusRestartsTotalFamilyGenerator() generator.Family } func createPodInitContainerStatusRunningFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_init_container_status_running", "Describes whether the init container is currently in running state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.InitContainerStatuses)) @@ -896,10 +910,11 @@ func createPodInitContainerStatusRunningFamilyGenerator() generator.FamilyGenera } func createPodInitContainerStatusTerminatedFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_init_container_status_terminated", "Describes whether the init container is currently in terminated state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.InitContainerStatuses)) @@ -945,10 +960,11 @@ func createPodInitContainerStatusTerminatedReasonFamilyGenerator() generator.Fam } func createPodInitContainerStatusWaitingFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_init_container_status_waiting", "Describes whether the init container is currently in waiting state.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := make([]*metric.Metric, len(p.Status.InitContainerStatuses)) @@ -1015,10 +1031,11 @@ func createPodAnnotationsGenerator(allowAnnotations []string) generator.FamilyGe } func createPodLabelsGenerator(allowLabelsList []string) generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_labels", "Kubernetes labels converted to Prometheus labels.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", p.Labels, allowLabelsList) @@ -1086,10 +1103,11 @@ func createPodOverheadMemoryBytesFamilyGenerator() generator.FamilyGenerator { } func createPodOwnerFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_owner", "Information about the Pod's owner.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { labelKeys := []string{"owner_kind", "owner_name", "owner_is_controller"} @@ -1133,10 +1151,11 @@ func createPodOwnerFamilyGenerator() generator.FamilyGenerator { } func createPodRestartPolicyFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_restart_policy", "Describes the restart policy in use by this pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { return &metric.Family{ @@ -1177,10 +1196,11 @@ func createPodRuntimeClassNameInfoFamilyGenerator() generator.FamilyGenerator { } func createPodSpecVolumesPersistentVolumeClaimsInfoFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_spec_volumes_persistentvolumeclaims_info", "Information about persistentvolumeclaim volumes in a pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -1203,10 +1223,11 @@ func createPodSpecVolumesPersistentVolumeClaimsInfoFamilyGenerator() generator.F } func createPodSpecVolumesPersistentVolumeClaimsReadonlyFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_spec_volumes_persistentvolumeclaims_readonly", "Describes whether a persistentvolumeclaim is mounted read only.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -1229,10 +1250,11 @@ func createPodSpecVolumesPersistentVolumeClaimsReadonlyFamilyGenerator() generat } func createPodStartTimeFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_start_time", "Start time in unix timestamp for a pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -1252,10 +1274,11 @@ func createPodStartTimeFamilyGenerator() generator.FamilyGenerator { } func createPodStatusPhaseFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_status_phase", "The pods current phase.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { phase := p.Status.Phase @@ -1295,10 +1318,11 @@ func createPodStatusPhaseFamilyGenerator() generator.FamilyGenerator { } func createPodStatusReadyFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_status_ready", "Describes whether the pod is ready to serve requests.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -1351,10 +1375,11 @@ func createPodStatusReasonFamilyGenerator() generator.FamilyGenerator { } func createPodStatusScheduledFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_status_scheduled", "Describes the status of the scheduling process for the pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -1379,10 +1404,11 @@ func createPodStatusScheduledFamilyGenerator() generator.FamilyGenerator { } func createPodStatusScheduledTimeFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_status_scheduled_time", "Unix timestamp when pod moved into scheduled status", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} @@ -1405,10 +1431,11 @@ func createPodStatusScheduledTimeFamilyGenerator() generator.FamilyGenerator { } func createPodStatusUnschedulableFamilyGenerator() generator.FamilyGenerator { - return *generator.NewFamilyGenerator( + return *generator.NewFamilyGeneratorWithStability( "kube_pod_status_unschedulable", "Describes the unschedulable status for the pod.", metric.Gauge, + basemetrics.STABLE, "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/pod_test.go b/internal/store/pod_test.go index e08a7cfb78..e94ecc3190 100644 --- a/internal/store/pod_test.go +++ b/internal/store/pod_test.go @@ -62,7 +62,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_info Information about a container in a pod. + # HELP kube_pod_container_info [STABLE] Information about a container in a pod. # TYPE kube_pod_container_info gauge kube_pod_container_info{container="container1",container_id="docker://ab123",image="k8s.gcr.io/hyperkube1",image_spec="k8s.gcr.io/hyperkube1_spec",image_id="docker://sha256:aaa",namespace="ns1",pod="pod1",uid="uid1"} 1`, MetricNames: []string{"kube_pod_container_info"}, @@ -118,8 +118,8 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_info Information about a container in a pod. - # HELP kube_pod_init_container_info Information about an init container in a pod. + # HELP kube_pod_container_info [STABLE] Information about a container in a pod. + # HELP kube_pod_init_container_info [STABLE] Information about an init container in a pod. # TYPE kube_pod_container_info gauge # TYPE kube_pod_init_container_info gauge kube_pod_container_info{container="container2",container_id="docker://cd456",image_spec="k8s.gcr.io/hyperkube2_spec",image="k8s.gcr.io/hyperkube2",image_id="docker://sha256:bbb",namespace="ns2",pod="pod2",uid="uid2"} 1 @@ -152,7 +152,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_ready Describes whether the containers readiness check succeeded. + # HELP kube_pod_container_status_ready [STABLE] Describes whether the containers readiness check succeeded. # TYPE kube_pod_container_status_ready gauge kube_pod_container_status_ready{container="container1",namespace="ns1",pod="pod1",uid="uid1"} 1`, MetricNames: []string{"kube_pod_container_status_ready"}, @@ -190,7 +190,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_ready Describes whether the containers readiness check succeeded. + # HELP kube_pod_container_status_ready [STABLE] Describes whether the containers readiness check succeeded. # TYPE kube_pod_container_status_ready gauge kube_pod_container_status_ready{container="container2",namespace="ns2",pod="pod2",uid="uid2"} 1 kube_pod_container_status_ready{container="container3",namespace="ns2",pod="pod2",uid="uid2"} 0 @@ -250,7 +250,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_init_container_status_ready Describes whether the init containers readiness check succeeded. + # HELP kube_pod_init_container_status_ready [STABLE] Describes whether the init containers readiness check succeeded. # TYPE kube_pod_init_container_status_ready gauge kube_pod_init_container_status_ready{container="initcontainer1",namespace="ns3",pod="pod3",uid="uid3"} 1 kube_pod_init_container_status_ready{container="initcontainer2",namespace="ns3",pod="pod3",uid="uid3"} 0 @@ -282,7 +282,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_restarts_total The number of container restarts per container. + # HELP kube_pod_container_status_restarts_total [STABLE] The number of container restarts per container. # TYPE kube_pod_container_status_restarts_total counter kube_pod_container_status_restarts_total{container="container1",namespace="ns1",pod="pod1",uid="uid1"} 0 `, @@ -313,7 +313,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_init_container_status_restarts_total The number of restarts for the init container. + # HELP kube_pod_init_container_status_restarts_total [STABLE] The number of restarts for the init container. # TYPE kube_pod_init_container_status_restarts_total counter kube_pod_init_container_status_restarts_total{container="initcontainer1",namespace="ns2",pod="pod2",uid="uid2"} 1 `, @@ -352,7 +352,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_restarts_total The number of container restarts per container. + # HELP kube_pod_container_status_restarts_total [STABLE] The number of container restarts per container. # TYPE kube_pod_container_status_restarts_total counter kube_pod_container_status_restarts_total{container="container2",namespace="ns2",pod="pod2",uid="uid2"} 0 kube_pod_container_status_restarts_total{container="container3",namespace="ns2",pod="pod2",uid="uid2"} 1 @@ -392,7 +392,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_init_container_status_restarts_total The number of restarts for the init container. + # HELP kube_pod_init_container_status_restarts_total [STABLE] The number of restarts for the init container. # TYPE kube_pod_init_container_status_restarts_total counter kube_pod_init_container_status_restarts_total{container="initcontainer2",namespace="ns2",pod="pod2",uid="uid2"} 0 kube_pod_init_container_status_restarts_total{container="initcontainer3",namespace="ns2",pod="pod2",uid="uid2"} 1 @@ -444,16 +444,16 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_state_started [STABLE] Start time in unix timestamp for a pod container. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. - # HELP kube_pod_init_container_status_running Describes whether the init container is currently in running state. - # HELP kube_pod_init_container_status_terminated Describes whether the init container is currently in terminated state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. + # HELP kube_pod_init_container_status_running [STABLE] Describes whether the init container is currently in running state. + # HELP kube_pod_init_container_status_terminated [STABLE] Describes whether the init container is currently in terminated state. # HELP kube_pod_init_container_status_terminated_reason Describes the reason the init container is currently in terminated state. - # HELP kube_pod_init_container_status_waiting Describes whether the init container is currently in waiting state. + # HELP kube_pod_init_container_status_waiting [STABLE] Describes whether the init container is currently in waiting state. # HELP kube_pod_init_container_status_waiting_reason Describes the reason the init container is currently in waiting state. # TYPE kube_pod_container_status_running gauge # TYPE kube_pod_container_state_started gauge @@ -519,12 +519,12 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_state_started [STABLE] Start time in unix timestamp for a pod container. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_running gauge # TYPE kube_pod_container_state_started gauge # TYPE kube_pod_container_status_terminated gauge @@ -590,12 +590,12 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_state_started [STABLE] Start time in unix timestamp for a pod container. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_running gauge # TYPE kube_pod_container_state_started gauge # TYPE kube_pod_container_status_terminated gauge @@ -651,11 +651,11 @@ func TestPodStore(t *testing.T) { Want: ` # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state. # HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state. - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_last_terminated_exitcode gauge # TYPE kube_pod_container_status_last_terminated_reason gauge # TYPE kube_pod_container_status_running gauge @@ -727,12 +727,12 @@ func TestPodStore(t *testing.T) { Want: ` # HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state. # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state. - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. - # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_state_started [STABLE] Start time in unix timestamp for a pod container. # TYPE kube_pod_container_status_last_terminated_reason gauge # TYPE kube_pod_container_status_last_terminated_exitcode gauge # TYPE kube_pod_container_status_running gauge @@ -797,12 +797,12 @@ func TestPodStore(t *testing.T) { Want: ` # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state. # HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state. - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_state_started [STABLE] Start time in unix timestamp for a pod container. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_last_terminated_exitcode gauge # TYPE kube_pod_container_status_last_terminated_reason gauge # TYPE kube_pod_container_status_running gauge @@ -857,11 +857,11 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_running gauge # TYPE kube_pod_container_status_terminated gauge # TYPE kube_pod_container_status_terminated_reason gauge @@ -909,11 +909,11 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_running gauge # TYPE kube_pod_container_status_terminated gauge # TYPE kube_pod_container_status_terminated_reason gauge @@ -961,11 +961,11 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_container_status_running Describes whether the container is currently in running state. - # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. + # HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. + # HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. - # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. - # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. + # HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. + # HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. # TYPE kube_pod_container_status_running gauge # TYPE kube_pod_container_status_terminated gauge # TYPE kube_pod_container_status_terminated_reason gauge @@ -1019,12 +1019,12 @@ func TestPodStore(t *testing.T) { }, // TODO: Should it be '1501569018' instead? Want: ` - # HELP kube_pod_completion_time Completion time in unix timestamp for a pod. - # HELP kube_pod_created Unix creation timestamp - # HELP kube_pod_info Information about pod. + # HELP kube_pod_completion_time [STABLE] Completion time in unix timestamp for a pod. + # HELP kube_pod_created [STABLE] Unix creation timestamp + # HELP kube_pod_info [STABLE] Information about pod. # HELP kube_pod_ips Pod IP addresses - # HELP kube_pod_owner Information about the Pod's owner. - # HELP kube_pod_start_time Start time in unix timestamp for a pod. + # HELP kube_pod_owner [STABLE] Information about the Pod's owner. + # HELP kube_pod_start_time [STABLE] Start time in unix timestamp for a pod. # TYPE kube_pod_completion_time gauge # TYPE kube_pod_created gauge # TYPE kube_pod_info gauge @@ -1078,7 +1078,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_restart_policy Describes the restart policy in use by this pod. + # HELP kube_pod_restart_policy [STABLE] Describes the restart policy in use by this pod. # TYPE kube_pod_restart_policy gauge kube_pod_restart_policy{namespace="ns2",pod="pod2",type="Always",uid="uid2"} 1 `, @@ -1096,7 +1096,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_restart_policy Describes the restart policy in use by this pod. + # HELP kube_pod_restart_policy [STABLE] Describes the restart policy in use by this pod. # TYPE kube_pod_restart_policy gauge kube_pod_restart_policy{namespace="ns2",pod="pod2",type="OnFailure",uid="uid2"} 1 `, @@ -1180,11 +1180,11 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_completion_time Completion time in unix timestamp for a pod. - # HELP kube_pod_created Unix creation timestamp - # HELP kube_pod_info Information about pod. - # HELP kube_pod_owner Information about the Pod's owner. - # HELP kube_pod_start_time Start time in unix timestamp for a pod. + # HELP kube_pod_completion_time [STABLE] Completion time in unix timestamp for a pod. + # HELP kube_pod_created [STABLE] Unix creation timestamp + # HELP kube_pod_info [STABLE] Information about pod. + # HELP kube_pod_owner [STABLE] Information about the Pod's owner. + # HELP kube_pod_start_time [STABLE] Start time in unix timestamp for a pod. # TYPE kube_pod_completion_time gauge # TYPE kube_pod_created gauge # TYPE kube_pod_info gauge @@ -1208,7 +1208,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_phase The pods current phase. + # HELP kube_pod_status_phase [STABLE] The pods current phase. # TYPE kube_pod_status_phase gauge kube_pod_status_phase{namespace="ns1",phase="Failed",pod="pod1",uid="uid1"} 0 kube_pod_status_phase{namespace="ns1",phase="Pending",pod="pod1",uid="uid1"} 0 @@ -1230,7 +1230,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_phase The pods current phase. + # HELP kube_pod_status_phase [STABLE] The pods current phase. # TYPE kube_pod_status_phase gauge kube_pod_status_phase{namespace="ns2",phase="Failed",pod="pod2",uid="uid2"} 0 kube_pod_status_phase{namespace="ns2",phase="Pending",pod="pod2",uid="uid2"} 1 @@ -1253,7 +1253,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_phase The pods current phase. + # HELP kube_pod_status_phase [STABLE] The pods current phase. # TYPE kube_pod_status_phase gauge kube_pod_status_phase{namespace="ns3",phase="Failed",pod="pod3",uid="uid3"} 0 kube_pod_status_phase{namespace="ns3",phase="Pending",pod="pod3",uid="uid3"} 0 @@ -1277,7 +1277,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_phase The pods current phase. + # HELP kube_pod_status_phase [STABLE] The pods current phase. # HELP kube_pod_status_reason The pod status reasons # TYPE kube_pod_status_phase gauge # TYPE kube_pod_status_reason gauge @@ -1431,7 +1431,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_ready Describes whether the pod is ready to serve requests. + # HELP kube_pod_status_ready [STABLE] Describes whether the pod is ready to serve requests. # TYPE kube_pod_status_ready gauge kube_pod_status_ready{condition="false",namespace="ns1",pod="pod1",uid="uid1"} 0 kube_pod_status_ready{condition="true",namespace="ns1",pod="pod1",uid="uid1"} 1 @@ -1456,7 +1456,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_ready Describes whether the pod is ready to serve requests. + # HELP kube_pod_status_ready [STABLE] Describes whether the pod is ready to serve requests. # TYPE kube_pod_status_ready gauge kube_pod_status_ready{condition="false",namespace="ns2",pod="pod2",uid="uid2"} 1 kube_pod_status_ready{condition="true",namespace="ns2",pod="pod2",uid="uid2"} 0 @@ -1484,8 +1484,8 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_scheduled Describes the status of the scheduling process for the pod. - # HELP kube_pod_status_scheduled_time Unix timestamp when pod moved into scheduled status + # HELP kube_pod_status_scheduled [STABLE] Describes the status of the scheduling process for the pod. + # HELP kube_pod_status_scheduled_time [STABLE] Unix timestamp when pod moved into scheduled status # TYPE kube_pod_status_scheduled gauge # TYPE kube_pod_status_scheduled_time gauge kube_pod_status_scheduled_time{namespace="ns1",pod="pod1",uid="uid1"} 1.501666018e+09 @@ -1512,8 +1512,8 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_scheduled Describes the status of the scheduling process for the pod. - # HELP kube_pod_status_scheduled_time Unix timestamp when pod moved into scheduled status + # HELP kube_pod_status_scheduled [STABLE] Describes the status of the scheduling process for the pod. + # HELP kube_pod_status_scheduled_time [STABLE] Unix timestamp when pod moved into scheduled status # TYPE kube_pod_status_scheduled gauge # TYPE kube_pod_status_scheduled_time gauge kube_pod_status_scheduled{condition="false",namespace="ns2",pod="pod2",uid="uid2"} 1 @@ -1541,7 +1541,7 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_status_unschedulable Describes the unschedulable status for the pod. + # HELP kube_pod_status_unschedulable [STABLE] Describes the unschedulable status for the pod. # TYPE kube_pod_status_unschedulable gauge kube_pod_status_unschedulable{namespace="ns2",pod="pod2",uid="uid2"} 1 `, @@ -1742,7 +1742,7 @@ func TestPodStore(t *testing.T) { Spec: v1.PodSpec{}, }, Want: ` - # HELP kube_pod_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_pod_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_pod_labels gauge kube_pod_labels{namespace="ns1",pod="pod1",uid="uid1"} 1 `, @@ -1792,8 +1792,8 @@ func TestPodStore(t *testing.T) { }, }, Want: ` - # HELP kube_pod_spec_volumes_persistentvolumeclaims_info Information about persistentvolumeclaim volumes in a pod. - # HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly Describes whether a persistentvolumeclaim is mounted read only. + # HELP kube_pod_spec_volumes_persistentvolumeclaims_info [STABLE] Information about persistentvolumeclaim volumes in a pod. + # HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only. # TYPE kube_pod_spec_volumes_persistentvolumeclaims_info gauge # TYPE kube_pod_spec_volumes_persistentvolumeclaims_readonly gauge kube_pod_spec_volumes_persistentvolumeclaims_info{namespace="ns1",persistentvolumeclaim="claim1",pod="pod1",volume="myvol",uid="uid1"} 1 @@ -1844,7 +1844,7 @@ func TestPodStore(t *testing.T) { }, AllowLabelsList: []string{"wildcard-not-first", options.LabelWildcard}, Want: ` - # HELP kube_pod_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_pod_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_pod_labels gauge kube_pod_labels{namespace="ns1",pod="pod1",uid="uid1"} 1 `, @@ -1866,7 +1866,7 @@ func TestPodStore(t *testing.T) { }, AllowLabelsList: []string{options.LabelWildcard}, Want: ` - # HELP kube_pod_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_pod_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_pod_labels gauge kube_pod_labels{label_app="example",namespace="ns1",pod="pod1",uid="uid1"} 1 `, diff --git a/internal/store/poddisruptionbudget.go b/internal/store/poddisruptionbudget.go index 737358c19b..c97055a794 100644 --- a/internal/store/poddisruptionbudget.go +++ b/internal/store/poddisruptionbudget.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -76,10 +77,11 @@ func podDisruptionBudgetMetricFamilies(allowAnnotationsList, allowLabelsList []s } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_poddisruptionbudget_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapPodDisruptionBudgetFunc(func(p *policyv1.PodDisruptionBudget) *metric.Family { ms := []*metric.Metric{} @@ -95,10 +97,11 @@ func podDisruptionBudgetMetricFamilies(allowAnnotationsList, allowLabelsList []s } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_poddisruptionbudget_status_current_healthy", "Current number of healthy pods", metric.Gauge, + basemetrics.STABLE, "", wrapPodDisruptionBudgetFunc(func(p *policyv1.PodDisruptionBudget) *metric.Family { return &metric.Family{ @@ -110,10 +113,11 @@ func podDisruptionBudgetMetricFamilies(allowAnnotationsList, allowLabelsList []s } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_poddisruptionbudget_status_desired_healthy", "Minimum desired number of healthy pods", metric.Gauge, + basemetrics.STABLE, "", wrapPodDisruptionBudgetFunc(func(p *policyv1.PodDisruptionBudget) *metric.Family { return &metric.Family{ @@ -125,10 +129,11 @@ func podDisruptionBudgetMetricFamilies(allowAnnotationsList, allowLabelsList []s } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_poddisruptionbudget_status_pod_disruptions_allowed", "Number of pod disruptions that are currently allowed", metric.Gauge, + basemetrics.STABLE, "", wrapPodDisruptionBudgetFunc(func(p *policyv1.PodDisruptionBudget) *metric.Family { return &metric.Family{ @@ -140,10 +145,11 @@ func podDisruptionBudgetMetricFamilies(allowAnnotationsList, allowLabelsList []s } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_poddisruptionbudget_status_expected_pods", "Total number of pods counted by this disruption budget", metric.Gauge, + basemetrics.STABLE, "", wrapPodDisruptionBudgetFunc(func(p *policyv1.PodDisruptionBudget) *metric.Family { return &metric.Family{ @@ -155,10 +161,11 @@ func podDisruptionBudgetMetricFamilies(allowAnnotationsList, allowLabelsList []s } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_poddisruptionbudget_status_observed_generation", "Most recent generation observed when updating this PDB status", metric.Gauge, + basemetrics.STABLE, "", wrapPodDisruptionBudgetFunc(func(p *policyv1.PodDisruptionBudget) *metric.Family { return &metric.Family{ diff --git a/internal/store/poddisruptionbudget_test.go b/internal/store/poddisruptionbudget_test.go index ba67bb1cf2..33586c1ca4 100644 --- a/internal/store/poddisruptionbudget_test.go +++ b/internal/store/poddisruptionbudget_test.go @@ -36,17 +36,17 @@ func TestPodDisruptionBudgetStore(t *testing.T) { # TYPE kube_poddisruptionbudget_labels gauge ` const metadata = labelsAndAnnotationsMetaData + ` - # HELP kube_poddisruptionbudget_created Unix creation timestamp + # HELP kube_poddisruptionbudget_created [STABLE] Unix creation timestamp # TYPE kube_poddisruptionbudget_created gauge - # HELP kube_poddisruptionbudget_status_current_healthy Current number of healthy pods + # HELP kube_poddisruptionbudget_status_current_healthy [STABLE] Current number of healthy pods # TYPE kube_poddisruptionbudget_status_current_healthy gauge - # HELP kube_poddisruptionbudget_status_desired_healthy Minimum desired number of healthy pods + # HELP kube_poddisruptionbudget_status_desired_healthy [STABLE] Minimum desired number of healthy pods # TYPE kube_poddisruptionbudget_status_desired_healthy gauge - # HELP kube_poddisruptionbudget_status_pod_disruptions_allowed Number of pod disruptions that are currently allowed + # HELP kube_poddisruptionbudget_status_pod_disruptions_allowed [STABLE] Number of pod disruptions that are currently allowed # TYPE kube_poddisruptionbudget_status_pod_disruptions_allowed gauge - # HELP kube_poddisruptionbudget_status_expected_pods Total number of pods counted by this disruption budget + # HELP kube_poddisruptionbudget_status_expected_pods [STABLE] Total number of pods counted by this disruption budget # TYPE kube_poddisruptionbudget_status_expected_pods gauge - # HELP kube_poddisruptionbudget_status_observed_generation Most recent generation observed when updating this PDB status + # HELP kube_poddisruptionbudget_status_observed_generation [STABLE] Most recent generation observed when updating this PDB status # TYPE kube_poddisruptionbudget_status_observed_generation gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/replicaset.go b/internal/store/replicaset.go index 75bb1d8ddb..7ea4cff730 100644 --- a/internal/store/replicaset.go +++ b/internal/store/replicaset.go @@ -20,6 +20,8 @@ import ( "context" "strconv" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -41,10 +43,11 @@ var ( func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { ms := []*metric.Metric{} @@ -61,10 +64,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_status_replicas", "The number of replicas per ReplicaSet.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { return &metric.Family{ @@ -76,10 +80,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_status_fully_labeled_replicas", "The number of fully labeled replicas per ReplicaSet.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { return &metric.Family{ @@ -91,10 +96,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_status_ready_replicas", "The number of ready replicas per ReplicaSet.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { return &metric.Family{ @@ -106,10 +112,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_status_observed_generation", "The generation observed by the ReplicaSet controller.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { return &metric.Family{ @@ -121,10 +128,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_spec_replicas", "Number of desired pods for a ReplicaSet.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { ms := []*metric.Metric{} @@ -140,10 +148,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_metadata_generation", "Sequence number representing a specific generation of the desired state.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { return &metric.Family{ @@ -155,10 +164,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicaset_owner", "Information about the ReplicaSet's owner.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { owners := r.GetOwnerReferences() @@ -217,10 +227,11 @@ func replicaSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [] } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descReplicaSetLabelsName, descReplicaSetLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapReplicaSetFunc(func(r *v1.ReplicaSet) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", r.Labels, allowLabelsList) diff --git a/internal/store/replicaset_test.go b/internal/store/replicaset_test.go index 7735c95308..f25d51e275 100644 --- a/internal/store/replicaset_test.go +++ b/internal/store/replicaset_test.go @@ -38,23 +38,23 @@ func TestReplicaSetStore(t *testing.T) { const metadata = ` # HELP kube_replicaset_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_replicaset_annotations gauge - # HELP kube_replicaset_created Unix creation timestamp + # HELP kube_replicaset_created [STABLE] Unix creation timestamp # TYPE kube_replicaset_created gauge - # HELP kube_replicaset_metadata_generation Sequence number representing a specific generation of the desired state. + # HELP kube_replicaset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state. # TYPE kube_replicaset_metadata_generation gauge - # HELP kube_replicaset_status_replicas The number of replicas per ReplicaSet. + # HELP kube_replicaset_status_replicas [STABLE] The number of replicas per ReplicaSet. # TYPE kube_replicaset_status_replicas gauge - # HELP kube_replicaset_status_fully_labeled_replicas The number of fully labeled replicas per ReplicaSet. + # HELP kube_replicaset_status_fully_labeled_replicas [STABLE] The number of fully labeled replicas per ReplicaSet. # TYPE kube_replicaset_status_fully_labeled_replicas gauge - # HELP kube_replicaset_status_ready_replicas The number of ready replicas per ReplicaSet. + # HELP kube_replicaset_status_ready_replicas [STABLE] The number of ready replicas per ReplicaSet. # TYPE kube_replicaset_status_ready_replicas gauge - # HELP kube_replicaset_status_observed_generation The generation observed by the ReplicaSet controller. + # HELP kube_replicaset_status_observed_generation [STABLE] The generation observed by the ReplicaSet controller. # TYPE kube_replicaset_status_observed_generation gauge - # HELP kube_replicaset_spec_replicas Number of desired pods for a ReplicaSet. + # HELP kube_replicaset_spec_replicas [STABLE] Number of desired pods for a ReplicaSet. # TYPE kube_replicaset_spec_replicas gauge - # HELP kube_replicaset_owner Information about the ReplicaSet's owner. + # HELP kube_replicaset_owner [STABLE] Information about the ReplicaSet's owner. # TYPE kube_replicaset_owner gauge - # HELP kube_replicaset_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_replicaset_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_replicaset_labels gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/replicationcontroller.go b/internal/store/replicationcontroller.go index 0abcc5b107..f5da7f5bdb 100644 --- a/internal/store/replicationcontroller.go +++ b/internal/store/replicationcontroller.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -35,10 +36,11 @@ var ( descReplicationControllerLabelsDefaultLabels = []string{"namespace", "replicationcontroller"} replicationControllerMetricFamilies = []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { ms := []*metric.Metric{} @@ -54,10 +56,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_status_replicas", "The number of replicas per ReplicationController.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { return &metric.Family{ @@ -69,10 +72,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_status_fully_labeled_replicas", "The number of fully labeled replicas per ReplicationController.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { return &metric.Family{ @@ -84,10 +88,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_status_ready_replicas", "The number of ready replicas per ReplicationController.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { return &metric.Family{ @@ -99,10 +104,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_status_available_replicas", "The number of available replicas per ReplicationController.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { return &metric.Family{ @@ -114,10 +120,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_status_observed_generation", "The generation observed by the ReplicationController controller.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { return &metric.Family{ @@ -129,10 +136,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_spec_replicas", "Number of desired pods for a ReplicationController.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { ms := []*metric.Metric{} @@ -148,10 +156,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_replicationcontroller_metadata_generation", "Sequence number representing a specific generation of the desired state.", metric.Gauge, + basemetrics.STABLE, "", wrapReplicationControllerFunc(func(r *v1.ReplicationController) *metric.Family { return &metric.Family{ diff --git a/internal/store/replicationcontroller_test.go b/internal/store/replicationcontroller_test.go index f5111d21a4..f125d294c3 100644 --- a/internal/store/replicationcontroller_test.go +++ b/internal/store/replicationcontroller_test.go @@ -38,23 +38,23 @@ func TestReplicationControllerStore(t *testing.T) { // Fixed metadata on type and help text. We prepend this to every expected // output so we only have to modify a single place when doing adjustments. const metadata = ` - # HELP kube_replicationcontroller_created Unix creation timestamp + # HELP kube_replicationcontroller_created [STABLE] Unix creation timestamp # TYPE kube_replicationcontroller_created gauge - # HELP kube_replicationcontroller_metadata_generation Sequence number representing a specific generation of the desired state. + # HELP kube_replicationcontroller_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state. # TYPE kube_replicationcontroller_metadata_generation gauge # HELP kube_replicationcontroller_owner Information about the ReplicationController's owner. # TYPE kube_replicationcontroller_owner gauge - # HELP kube_replicationcontroller_status_replicas The number of replicas per ReplicationController. + # HELP kube_replicationcontroller_status_replicas [STABLE] The number of replicas per ReplicationController. # TYPE kube_replicationcontroller_status_replicas gauge - # HELP kube_replicationcontroller_status_fully_labeled_replicas The number of fully labeled replicas per ReplicationController. + # HELP kube_replicationcontroller_status_fully_labeled_replicas [STABLE] The number of fully labeled replicas per ReplicationController. # TYPE kube_replicationcontroller_status_fully_labeled_replicas gauge - # HELP kube_replicationcontroller_status_available_replicas The number of available replicas per ReplicationController. + # HELP kube_replicationcontroller_status_available_replicas [STABLE] The number of available replicas per ReplicationController. # TYPE kube_replicationcontroller_status_available_replicas gauge - # HELP kube_replicationcontroller_status_ready_replicas The number of ready replicas per ReplicationController. + # HELP kube_replicationcontroller_status_ready_replicas [STABLE] The number of ready replicas per ReplicationController. # TYPE kube_replicationcontroller_status_ready_replicas gauge - # HELP kube_replicationcontroller_status_observed_generation The generation observed by the ReplicationController controller. + # HELP kube_replicationcontroller_status_observed_generation [STABLE] The generation observed by the ReplicationController controller. # TYPE kube_replicationcontroller_status_observed_generation gauge - # HELP kube_replicationcontroller_spec_replicas Number of desired pods for a ReplicationController. + # HELP kube_replicationcontroller_spec_replicas [STABLE] Number of desired pods for a ReplicationController. # TYPE kube_replicationcontroller_spec_replicas gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/resourcequota.go b/internal/store/resourcequota.go index 9cef38ae9b..fe55f98f0b 100644 --- a/internal/store/resourcequota.go +++ b/internal/store/resourcequota.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -34,10 +35,11 @@ var ( descResourceQuotaLabelsDefaultLabels = []string{"namespace", "resourcequota"} resourceQuotaMetricFamilies = []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_resourcequota_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapResourceQuotaFunc(func(r *v1.ResourceQuota) *metric.Family { ms := []*metric.Metric{} @@ -54,10 +56,11 @@ var ( } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_resourcequota", "Information about resource quota.", metric.Gauge, + basemetrics.STABLE, "", wrapResourceQuotaFunc(func(r *v1.ResourceQuota) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/resourcequota_test.go b/internal/store/resourcequota_test.go index 405f9935ed..f342065cc3 100644 --- a/internal/store/resourcequota_test.go +++ b/internal/store/resourcequota_test.go @@ -31,9 +31,9 @@ func TestResourceQuotaStore(t *testing.T) { // Fixed metadata on type and help text. We prepend this to every expected // output so we only have to modify a single place when doing adjustments. const metadata = ` - # HELP kube_resourcequota Information about resource quota. + # HELP kube_resourcequota [STABLE] Information about resource quota. # TYPE kube_resourcequota gauge - # HELP kube_resourcequota_created Unix creation timestamp + # HELP kube_resourcequota_created [STABLE] Unix creation timestamp # TYPE kube_resourcequota_created gauge ` cases := []generateMetricsTestCase{ diff --git a/internal/store/secret.go b/internal/store/secret.go index c11feb3928..fee2a2c8a3 100644 --- a/internal/store/secret.go +++ b/internal/store/secret.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +41,11 @@ var ( func secretMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_secret_info", "Information about secret.", metric.Gauge, + basemetrics.STABLE, "", wrapSecretFunc(func(s *v1.Secret) *metric.Family { return &metric.Family{ @@ -55,10 +57,11 @@ func secretMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gene } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_secret_type", "Type about secret.", metric.Gauge, + basemetrics.STABLE, "", wrapSecretFunc(func(s *v1.Secret) *metric.Family { return &metric.Family{ @@ -91,10 +94,11 @@ func secretMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gene }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descSecretLabelsName, descSecretLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapSecretFunc(func(s *v1.Secret) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", s.Labels, allowLabelsList) @@ -110,10 +114,11 @@ func secretMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gene }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_secret_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapSecretFunc(func(s *v1.Secret) *metric.Family { ms := []*metric.Metric{} diff --git a/internal/store/secret_test.go b/internal/store/secret_test.go index 96f88e1753..bb10cc6107 100644 --- a/internal/store/secret_test.go +++ b/internal/store/secret_test.go @@ -39,11 +39,11 @@ func TestSecretStore(t *testing.T) { Type: v1.SecretTypeOpaque, }, Want: ` - # HELP kube_secret_created Unix creation timestamp - # HELP kube_secret_info Information about secret. - # HELP kube_secret_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_secret_created [STABLE] Unix creation timestamp + # HELP kube_secret_info [STABLE] Information about secret. + # HELP kube_secret_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_secret_metadata_resource_version Resource version representing a specific version of secret. - # HELP kube_secret_type Type about secret. + # HELP kube_secret_type [STABLE] Type about secret. # TYPE kube_secret_created gauge # TYPE kube_secret_info gauge # TYPE kube_secret_labels gauge @@ -67,11 +67,11 @@ func TestSecretStore(t *testing.T) { Type: v1.SecretTypeServiceAccountToken, }, Want: ` - # HELP kube_secret_created Unix creation timestamp - # HELP kube_secret_info Information about secret. - # HELP kube_secret_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_secret_created [STABLE] Unix creation timestamp + # HELP kube_secret_info [STABLE] Information about secret. + # HELP kube_secret_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_secret_metadata_resource_version Resource version representing a specific version of secret. - # HELP kube_secret_type Type about secret. + # HELP kube_secret_type [STABLE] Type about secret. # TYPE kube_secret_created gauge # TYPE kube_secret_info gauge # TYPE kube_secret_labels gauge @@ -96,11 +96,11 @@ func TestSecretStore(t *testing.T) { Type: v1.SecretTypeDockercfg, }, Want: ` - # HELP kube_secret_created Unix creation timestamp - # HELP kube_secret_info Information about secret. - # HELP kube_secret_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_secret_created [STABLE] Unix creation timestamp + # HELP kube_secret_info [STABLE] Information about secret. + # HELP kube_secret_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_secret_metadata_resource_version Resource version representing a specific version of secret. - # HELP kube_secret_type Type about secret. + # HELP kube_secret_type [STABLE] Type about secret. # TYPE kube_secret_created gauge # TYPE kube_secret_info gauge # TYPE kube_secret_labels gauge diff --git a/internal/store/service.go b/internal/store/service.go index 549badeaaf..70bd011929 100644 --- a/internal/store/service.go +++ b/internal/store/service.go @@ -25,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/watch" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +41,11 @@ var ( func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_service_info", "Information about service.", metric.Gauge, + basemetrics.STABLE, "", wrapSvcFunc(func(s *v1.Service) *metric.Family { m := metric.Metric{ @@ -54,10 +56,11 @@ func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen return &metric.Family{Metrics: []*metric.Metric{&m}} }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_service_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapSvcFunc(func(s *v1.Service) *metric.Family { if !s.CreationTimestamp.IsZero() { @@ -71,10 +74,11 @@ func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen return &metric.Family{Metrics: []*metric.Metric{}} }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_service_spec_type", "Type about service.", metric.Gauge, + basemetrics.STABLE, "", wrapSvcFunc(func(s *v1.Service) *metric.Family { m := metric.Metric{ @@ -101,10 +105,11 @@ func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen return &metric.Family{Metrics: []*metric.Metric{&m}} }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descServiceLabelsName, descServiceLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapSvcFunc(func(s *v1.Service) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", s.Labels, allowLabelsList) @@ -116,10 +121,11 @@ func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen return &metric.Family{Metrics: []*metric.Metric{&m}} }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_service_spec_external_ip", "Service external ips. One series for each ip", metric.Gauge, + basemetrics.STABLE, "", wrapSvcFunc(func(s *v1.Service) *metric.Family { if len(s.Spec.ExternalIPs) == 0 { @@ -143,10 +149,11 @@ func serviceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_service_status_load_balancer_ingress", "Service load balancer ingress status", metric.Gauge, + basemetrics.STABLE, "", wrapSvcFunc(func(s *v1.Service) *metric.Family { if len(s.Status.LoadBalancer.Ingress) == 0 { diff --git a/internal/store/service_test.go b/internal/store/service_test.go index aa3ff17201..c291a48a08 100644 --- a/internal/store/service_test.go +++ b/internal/store/service_test.go @@ -32,17 +32,17 @@ func TestServiceStore(t *testing.T) { const metadata = ` # HELP kube_service_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_service_annotations gauge - # HELP kube_service_info Information about service. + # HELP kube_service_info [STABLE] Information about service. # TYPE kube_service_info gauge - # HELP kube_service_created Unix creation timestamp + # HELP kube_service_created [STABLE] Unix creation timestamp # TYPE kube_service_created gauge - # HELP kube_service_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_service_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_service_labels gauge - # HELP kube_service_spec_type Type about service. + # HELP kube_service_spec_type [STABLE] Type about service. # TYPE kube_service_spec_type gauge - # HELP kube_service_spec_external_ip Service external ips. One series for each ip + # HELP kube_service_spec_external_ip [STABLE] Service external ips. One series for each ip # TYPE kube_service_spec_external_ip gauge - # HELP kube_service_status_load_balancer_ingress Service load balancer ingress status + # HELP kube_service_status_load_balancer_ingress [STABLE] Service load balancer ingress status # TYPE kube_service_status_load_balancer_ingress gauge ` cases := []generateMetricsTestCase{ @@ -64,10 +64,10 @@ func TestServiceStore(t *testing.T) { }, Want: ` # HELP kube_service_annotations Kubernetes annotations converted to Prometheus labels. - # HELP kube_service_created Unix creation timestamp - # HELP kube_service_info Information about service. - # HELP kube_service_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_service_spec_type Type about service. + # HELP kube_service_created [STABLE] Unix creation timestamp + # HELP kube_service_info [STABLE] Information about service. + # HELP kube_service_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_service_spec_type [STABLE] Type about service. # TYPE kube_service_annotations gauge # TYPE kube_service_created gauge # TYPE kube_service_info gauge diff --git a/internal/store/statefulset.go b/internal/store/statefulset.go index 8d65aaae0d..af6020772e 100644 --- a/internal/store/statefulset.go +++ b/internal/store/statefulset.go @@ -19,6 +19,8 @@ package store import ( "context" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +42,11 @@ var ( func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { ms := []*metric.Metric{} @@ -59,10 +62,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_replicas", "The number of replicas per StatefulSet.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -89,10 +93,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_replicas_current", "The number of current replicas per StatefulSet.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -104,10 +109,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_replicas_ready", "The number of ready replicas per StatefulSet.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -119,10 +125,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_replicas_updated", "The number of updated replicas per StatefulSet.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -134,10 +141,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_observed_generation", "The generation observed by the StatefulSet controller.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -149,10 +157,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_replicas", "Number of desired pods for a StatefulSet.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { ms := []*metric.Metric{} @@ -168,10 +177,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_metadata_generation", "Sequence number representing a specific generation of the desired state for the StatefulSet.", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -201,10 +211,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descStatefulSetLabelsName, descStatefulSetLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", s.Labels, allowLabelsList) @@ -219,10 +230,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_current_revision", "Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ @@ -236,10 +248,11 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_statefulset_status_update_revision", "Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)", metric.Gauge, + basemetrics.STABLE, "", wrapStatefulSetFunc(func(s *v1.StatefulSet) *metric.Family { return &metric.Family{ diff --git a/internal/store/statefulset_test.go b/internal/store/statefulset_test.go index d5b65488eb..a6c63ee519 100644 --- a/internal/store/statefulset_test.go +++ b/internal/store/statefulset_test.go @@ -60,18 +60,18 @@ func TestStatefulSetStore(t *testing.T) { }, }, Want: ` - # HELP kube_statefulset_created Unix creation timestamp - # HELP kube_statefulset_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_statefulset_metadata_generation Sequence number representing a specific generation of the desired state for the StatefulSet. - # HELP kube_statefulset_replicas Number of desired pods for a StatefulSet. - # HELP kube_statefulset_status_current_revision Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas). - # HELP kube_statefulset_status_observed_generation The generation observed by the StatefulSet controller. - # HELP kube_statefulset_status_replicas The number of replicas per StatefulSet. + # HELP kube_statefulset_created [STABLE] Unix creation timestamp + # HELP kube_statefulset_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_statefulset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state for the StatefulSet. + # HELP kube_statefulset_replicas [STABLE] Number of desired pods for a StatefulSet. + # HELP kube_statefulset_status_current_revision [STABLE] Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas). + # HELP kube_statefulset_status_observed_generation [STABLE] The generation observed by the StatefulSet controller. + # HELP kube_statefulset_status_replicas [STABLE] The number of replicas per StatefulSet. # HELP kube_statefulset_status_replicas_available The number of available replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_current The number of current replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_ready The number of ready replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_updated The number of updated replicas per StatefulSet. - # HELP kube_statefulset_status_update_revision Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas) + # HELP kube_statefulset_status_replicas_current [STABLE] The number of current replicas per StatefulSet. + # HELP kube_statefulset_status_replicas_ready [STABLE] The number of ready replicas per StatefulSet. + # HELP kube_statefulset_status_replicas_updated [STABLE] The number of updated replicas per StatefulSet. + # HELP kube_statefulset_status_update_revision [STABLE] Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas) # TYPE kube_statefulset_created gauge # TYPE kube_statefulset_labels gauge # TYPE kube_statefulset_metadata_generation gauge @@ -138,17 +138,17 @@ func TestStatefulSetStore(t *testing.T) { }, }, Want: ` - # HELP kube_statefulset_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_statefulset_metadata_generation Sequence number representing a specific generation of the desired state for the StatefulSet. - # HELP kube_statefulset_replicas Number of desired pods for a StatefulSet. - # HELP kube_statefulset_status_current_revision Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas). - # HELP kube_statefulset_status_observed_generation The generation observed by the StatefulSet controller. - # HELP kube_statefulset_status_replicas The number of replicas per StatefulSet. + # HELP kube_statefulset_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_statefulset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state for the StatefulSet. + # HELP kube_statefulset_replicas [STABLE] Number of desired pods for a StatefulSet. + # HELP kube_statefulset_status_current_revision [STABLE] Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas). + # HELP kube_statefulset_status_observed_generation [STABLE] The generation observed by the StatefulSet controller. + # HELP kube_statefulset_status_replicas [STABLE] The number of replicas per StatefulSet. # HELP kube_statefulset_status_replicas_available The number of available replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_current The number of current replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_ready The number of ready replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_updated The number of updated replicas per StatefulSet. - # HELP kube_statefulset_status_update_revision Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas) + # HELP kube_statefulset_status_replicas_current [STABLE] The number of current replicas per StatefulSet. + # HELP kube_statefulset_status_replicas_ready [STABLE] The number of ready replicas per StatefulSet. + # HELP kube_statefulset_status_replicas_updated [STABLE] The number of updated replicas per StatefulSet. + # HELP kube_statefulset_status_update_revision [STABLE] Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas) # TYPE kube_statefulset_labels gauge # TYPE kube_statefulset_metadata_generation gauge # TYPE kube_statefulset_replicas gauge @@ -208,16 +208,16 @@ func TestStatefulSetStore(t *testing.T) { }, }, Want: ` - # HELP kube_statefulset_labels Kubernetes labels converted to Prometheus labels. - # HELP kube_statefulset_metadata_generation Sequence number representing a specific generation of the desired state for the StatefulSet. - # HELP kube_statefulset_replicas Number of desired pods for a StatefulSet. - # HELP kube_statefulset_status_current_revision Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas). - # HELP kube_statefulset_status_replicas The number of replicas per StatefulSet. + # HELP kube_statefulset_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_statefulset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state for the StatefulSet. + # HELP kube_statefulset_replicas [STABLE] Number of desired pods for a StatefulSet. + # HELP kube_statefulset_status_current_revision [STABLE] Indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas). + # HELP kube_statefulset_status_replicas [STABLE] The number of replicas per StatefulSet. # HELP kube_statefulset_status_replicas_available The number of available replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_current The number of current replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_ready The number of ready replicas per StatefulSet. - # HELP kube_statefulset_status_replicas_updated The number of updated replicas per StatefulSet. - # HELP kube_statefulset_status_update_revision Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas) + # HELP kube_statefulset_status_replicas_current [STABLE] The number of current replicas per StatefulSet. + # HELP kube_statefulset_status_replicas_ready [STABLE] The number of ready replicas per StatefulSet. + # HELP kube_statefulset_status_replicas_updated [STABLE] The number of updated replicas per StatefulSet. + # HELP kube_statefulset_status_update_revision [STABLE] Indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas) # TYPE kube_statefulset_labels gauge # TYPE kube_statefulset_metadata_generation gauge # TYPE kube_statefulset_replicas gauge diff --git a/internal/store/storageclass.go b/internal/store/storageclass.go index a6650d8560..f7a4e2e072 100644 --- a/internal/store/storageclass.go +++ b/internal/store/storageclass.go @@ -16,6 +16,8 @@ package store import ( "context" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" @@ -40,10 +42,11 @@ var ( func storageClassMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_storageclass_info", "Information about storageclass.", metric.Gauge, + basemetrics.STABLE, "", wrapStorageClassFunc(func(s *storagev1.StorageClass) *metric.Family { @@ -64,10 +67,11 @@ func storageClassMetricFamilies(allowAnnotationsList, allowLabelsList []string) return &metric.Family{Metrics: []*metric.Metric{&m}} }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( "kube_storageclass_created", "Unix creation timestamp", metric.Gauge, + basemetrics.STABLE, "", wrapStorageClassFunc(func(s *storagev1.StorageClass) *metric.Family { ms := []*metric.Metric{} @@ -99,10 +103,11 @@ func storageClassMetricFamilies(allowAnnotationsList, allowLabelsList []string) } }), ), - *generator.NewFamilyGenerator( + *generator.NewFamilyGeneratorWithStability( descStorageClassLabelsName, descStorageClassLabelsHelp, metric.Gauge, + basemetrics.STABLE, "", wrapStorageClassFunc(func(s *storagev1.StorageClass) *metric.Family { labelKeys, labelValues := createPrometheusLabelKeysValues("label", s.Labels, allowLabelsList) diff --git a/internal/store/storageclass_test.go b/internal/store/storageclass_test.go index c1f6866241..4f086f4826 100644 --- a/internal/store/storageclass_test.go +++ b/internal/store/storageclass_test.go @@ -40,7 +40,7 @@ func TestStorageClassStore(t *testing.T) { VolumeBindingMode: &volumeBindingMode, }, Want: ` - # HELP kube_storageclass_info Information about storageclass. + # HELP kube_storageclass_info [STABLE] Information about storageclass. # TYPE kube_storageclass_info gauge kube_storageclass_info{storageclass="test_storageclass-info",provisioner="kubernetes.io/rbd",reclaim_policy="Delete",volume_binding_mode="Immediate"} 1 `, @@ -58,7 +58,7 @@ func TestStorageClassStore(t *testing.T) { VolumeBindingMode: nil, }, Want: ` - # HELP kube_storageclass_info Information about storageclass. + # HELP kube_storageclass_info [STABLE] Information about storageclass. # TYPE kube_storageclass_info gauge kube_storageclass_info{storageclass="test_storageclass-default-info",provisioner="kubernetes.io/rbd",reclaim_policy="Delete",volume_binding_mode="Immediate"} 1 `, @@ -77,7 +77,7 @@ func TestStorageClassStore(t *testing.T) { VolumeBindingMode: &volumeBindingMode, }, Want: ` - # HELP kube_storageclass_created Unix creation timestamp + # HELP kube_storageclass_created [STABLE] Unix creation timestamp # TYPE kube_storageclass_created gauge kube_storageclass_created{storageclass="test_kube_storageclass-created"} 1.501569018e+09 `, @@ -98,7 +98,7 @@ func TestStorageClassStore(t *testing.T) { VolumeBindingMode: &volumeBindingMode, }, Want: ` - # HELP kube_storageclass_labels Kubernetes labels converted to Prometheus labels. + # HELP kube_storageclass_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_storageclass_labels gauge kube_storageclass_labels{storageclass="test_storageclass-labels"} 1 `, diff --git a/pkg/app/server_test.go b/pkg/app/server_test.go index e1012dc5af..cba7e27fe3 100644 --- a/pkg/app/server_test.go +++ b/pkg/app/server_test.go @@ -191,50 +191,50 @@ func TestFullScrapeCycle(t *testing.T) { body, _ := io.ReadAll(resp.Body) expected := `# HELP kube_pod_annotations Kubernetes annotations converted to Prometheus labels. -# HELP kube_pod_completion_time Completion time in unix timestamp for a pod. -# HELP kube_pod_container_info Information about a container in a pod. +# HELP kube_pod_completion_time [STABLE] Completion time in unix timestamp for a pod. +# HELP kube_pod_container_info [STABLE] Information about a container in a pod. # HELP kube_pod_container_resource_limits The number of requested limit resource by a container. # HELP kube_pod_container_resource_requests The number of requested request resource by a container. -# HELP kube_pod_container_state_started Start time in unix timestamp for a pod container. +# HELP kube_pod_container_state_started [STABLE] Start time in unix timestamp for a pod container. # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state. # HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state. -# HELP kube_pod_container_status_ready Describes whether the containers readiness check succeeded. -# HELP kube_pod_container_status_restarts_total The number of container restarts per container. -# HELP kube_pod_container_status_running Describes whether the container is currently in running state. -# HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state. +# HELP kube_pod_container_status_ready [STABLE] Describes whether the containers readiness check succeeded. +# HELP kube_pod_container_status_restarts_total [STABLE] The number of container restarts per container. +# HELP kube_pod_container_status_running [STABLE] Describes whether the container is currently in running state. +# HELP kube_pod_container_status_terminated [STABLE] Describes whether the container is currently in terminated state. # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state. -# HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state. -# HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state. -# HELP kube_pod_created Unix creation timestamp +# HELP kube_pod_container_status_waiting [STABLE] Describes whether the container is currently in waiting state. +# HELP kube_pod_container_status_waiting_reason [STABLE] Describes the reason the container is currently in waiting state. +# HELP kube_pod_created [STABLE] Unix creation timestamp # HELP kube_pod_deletion_timestamp Unix deletion timestamp -# HELP kube_pod_info Information about pod. -# HELP kube_pod_init_container_info Information about an init container in a pod. +# HELP kube_pod_info [STABLE] Information about pod. +# HELP kube_pod_init_container_info [STABLE] Information about an init container in a pod. # HELP kube_pod_init_container_resource_limits The number of requested limit resource by an init container. # HELP kube_pod_init_container_resource_requests The number of requested request resource by an init container. # HELP kube_pod_init_container_status_last_terminated_reason Describes the last reason the init container was in terminated state. -# HELP kube_pod_init_container_status_ready Describes whether the init containers readiness check succeeded. -# HELP kube_pod_init_container_status_restarts_total The number of restarts for the init container. -# HELP kube_pod_init_container_status_running Describes whether the init container is currently in running state. -# HELP kube_pod_init_container_status_terminated Describes whether the init container is currently in terminated state. +# HELP kube_pod_init_container_status_ready [STABLE] Describes whether the init containers readiness check succeeded. +# HELP kube_pod_init_container_status_restarts_total [STABLE] The number of restarts for the init container. +# HELP kube_pod_init_container_status_running [STABLE] Describes whether the init container is currently in running state. +# HELP kube_pod_init_container_status_terminated [STABLE] Describes whether the init container is currently in terminated state. # HELP kube_pod_init_container_status_terminated_reason Describes the reason the init container is currently in terminated state. -# HELP kube_pod_init_container_status_waiting Describes whether the init container is currently in waiting state. +# HELP kube_pod_init_container_status_waiting [STABLE] Describes whether the init container is currently in waiting state. # HELP kube_pod_init_container_status_waiting_reason Describes the reason the init container is currently in waiting state. # HELP kube_pod_ips Pod IP addresses -# HELP kube_pod_labels Kubernetes labels converted to Prometheus labels. +# HELP kube_pod_labels [STABLE] Kubernetes labels converted to Prometheus labels. # HELP kube_pod_overhead_cpu_cores The pod overhead in regards to cpu cores associated with running a pod. # HELP kube_pod_overhead_memory_bytes The pod overhead in regards to memory associated with running a pod. # HELP kube_pod_runtimeclass_name_info The runtimeclass associated with the pod. -# HELP kube_pod_owner Information about the Pod's owner. -# HELP kube_pod_restart_policy Describes the restart policy in use by this pod. -# HELP kube_pod_spec_volumes_persistentvolumeclaims_info Information about persistentvolumeclaim volumes in a pod. -# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly Describes whether a persistentvolumeclaim is mounted read only. -# HELP kube_pod_start_time Start time in unix timestamp for a pod. -# HELP kube_pod_status_phase The pods current phase. -# HELP kube_pod_status_ready Describes whether the pod is ready to serve requests. +# HELP kube_pod_owner [STABLE] Information about the Pod's owner. +# HELP kube_pod_restart_policy [STABLE] Describes the restart policy in use by this pod. +# HELP kube_pod_spec_volumes_persistentvolumeclaims_info [STABLE] Information about persistentvolumeclaim volumes in a pod. +# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only. +# HELP kube_pod_start_time [STABLE] Start time in unix timestamp for a pod. +# HELP kube_pod_status_phase [STABLE] The pods current phase. +# HELP kube_pod_status_ready [STABLE] Describes whether the pod is ready to serve requests. # HELP kube_pod_status_reason The pod status reasons -# HELP kube_pod_status_scheduled Describes the status of the scheduling process for the pod. -# HELP kube_pod_status_scheduled_time Unix timestamp when pod moved into scheduled status -# HELP kube_pod_status_unschedulable Describes the unschedulable status for the pod. +# HELP kube_pod_status_scheduled [STABLE] Describes the status of the scheduling process for the pod. +# HELP kube_pod_status_scheduled_time [STABLE] Unix timestamp when pod moved into scheduled status +# HELP kube_pod_status_unschedulable [STABLE] Describes the unschedulable status for the pod. # HELP kube_pod_tolerations Information about the pod tolerations # TYPE kube_pod_annotations gauge # TYPE kube_pod_completion_time gauge diff --git a/pkg/metric_generator/generator.go b/pkg/metric_generator/generator.go index dfde430d21..9481a26ddd 100644 --- a/pkg/metric_generator/generator.go +++ b/pkg/metric_generator/generator.go @@ -20,6 +20,8 @@ import ( "fmt" "strings" + basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" ) @@ -33,16 +35,19 @@ type FamilyGenerator struct { Type metric.Type OptIn bool DeprecatedVersion string + StabilityLevel basemetrics.StabilityLevel GenerateFunc func(obj interface{}) *metric.Family } -// NewFamilyGenerator creates new FamilyGenerator instances. -func NewFamilyGenerator(name string, help string, metricType metric.Type, deprecatedVersion string, generateFunc func(obj interface{}) *metric.Family) *FamilyGenerator { +// NewFamilyGeneratorWithStability creates new FamilyGenerator instances with metric +// stabilityLevel. +func NewFamilyGeneratorWithStability(name string, help string, metricType metric.Type, stabilityLevel basemetrics.StabilityLevel, deprecatedVersion string, generateFunc func(obj interface{}) *metric.Family) *FamilyGenerator { f := &FamilyGenerator{ Name: name, Type: metricType, Help: help, OptIn: false, + StabilityLevel: stabilityLevel, DeprecatedVersion: deprecatedVersion, GenerateFunc: generateFunc, } @@ -52,6 +57,11 @@ func NewFamilyGenerator(name string, help string, metricType metric.Type, deprec return f } +// NewFamilyGenerator creates new FamilyGenerator instances. +func NewFamilyGenerator(name string, help string, metricType metric.Type, deprecatedVersion string, generateFunc func(obj interface{}) *metric.Family) *FamilyGenerator { + return NewFamilyGeneratorWithStability(name, help, metricType, basemetrics.ALPHA, deprecatedVersion, generateFunc) +} + // NewOptInFamilyGenerator creates new FamilyGenerator instances for opt-in metric families. func NewOptInFamilyGenerator(name string, help string, metricType metric.Type, deprecatedVersion string, generateFunc func(obj interface{}) *metric.Family) *FamilyGenerator { f := NewFamilyGenerator(name, help, metricType, deprecatedVersion, generateFunc) @@ -75,7 +85,13 @@ func (g *FamilyGenerator) generateHeader() string { header.WriteString("# HELP ") header.WriteString(g.Name) header.WriteByte(' ') - header.WriteString(g.Help) + // TODO(#1833): remove if-else after all metrics are attached with right + // StabilityLevel. + if g.StabilityLevel == basemetrics.STABLE { + header.WriteString(fmt.Sprintf("[%v] %v", g.StabilityLevel, g.Help)) + } else { + header.WriteString(g.Help) + } header.WriteByte('\n') header.WriteString("# TYPE ") header.WriteString(g.Name)