Skip to content

Commit 5995c1e

Browse files
Add all stable metrics
1 parent 75bce1c commit 5995c1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+754
-551
lines changed

internal/store/certificatesigningrequest.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package store
1919
import (
2020
"context"
2121

22+
basemetrics "k8s.io/component-base/metrics"
23+
2224
"k8s.io/kube-state-metrics/v2/pkg/metric"
2325
generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator"
2426

@@ -58,10 +60,11 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
5860
}
5961
}),
6062
),
61-
*generator.NewFamilyGenerator(
63+
*generator.NewFamilyGeneratorWithStability(
6264
descCSRLabelsName,
6365
descCSRLabelsHelp,
6466
metric.Gauge,
67+
basemetrics.STABLE,
6568
"",
6669
wrapCSRFunc(func(j *certv1.CertificateSigningRequest) *metric.Family {
6770
labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList)
@@ -76,10 +79,11 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
7679
}
7780
}),
7881
),
79-
*generator.NewFamilyGenerator(
82+
*generator.NewFamilyGeneratorWithStability(
8083
"kube_certificatesigningrequest_created",
8184
"Unix creation timestamp",
8285
metric.Gauge,
86+
basemetrics.STABLE,
8387
"",
8488
wrapCSRFunc(func(csr *certv1.CertificateSigningRequest) *metric.Family {
8589
ms := []*metric.Metric{}
@@ -96,21 +100,23 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
96100
}
97101
}),
98102
),
99-
*generator.NewFamilyGenerator(
103+
*generator.NewFamilyGeneratorWithStability(
100104
"kube_certificatesigningrequest_condition",
101105
"The number of each certificatesigningrequest condition",
102106
metric.Gauge,
107+
basemetrics.STABLE,
103108
"",
104109
wrapCSRFunc(func(csr *certv1.CertificateSigningRequest) *metric.Family {
105110
return &metric.Family{
106111
Metrics: addCSRConditionMetrics(csr.Status),
107112
}
108113
}),
109114
),
110-
*generator.NewFamilyGenerator(
115+
*generator.NewFamilyGeneratorWithStability(
111116
"kube_certificatesigningrequest_cert_length",
112117
"Length of the issued cert",
113118
metric.Gauge,
119+
basemetrics.STABLE,
114120
"",
115121
wrapCSRFunc(func(csr *certv1.CertificateSigningRequest) *metric.Family {
116122
return &metric.Family{

internal/store/certificatesigningrequest_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import (
2828

2929
func TestCsrStore(t *testing.T) {
3030
const metadata = `
31-
# HELP kube_certificatesigningrequest_labels Kubernetes labels converted to Prometheus labels.
31+
# HELP kube_certificatesigningrequest_labels [STABLE] Kubernetes labels converted to Prometheus labels.
3232
# TYPE kube_certificatesigningrequest_labels gauge
33-
# HELP kube_certificatesigningrequest_created Unix creation timestamp
33+
# HELP kube_certificatesigningrequest_created [STABLE] Unix creation timestamp
3434
# TYPE kube_certificatesigningrequest_created gauge
35-
# HELP kube_certificatesigningrequest_condition The number of each certificatesigningrequest condition
35+
# HELP kube_certificatesigningrequest_condition [STABLE] The number of each certificatesigningrequest condition
3636
# TYPE kube_certificatesigningrequest_condition gauge
37-
# HELP kube_certificatesigningrequest_cert_length Length of the issued cert
37+
# HELP kube_certificatesigningrequest_cert_length [STABLE] Length of the issued cert
3838
# TYPE kube_certificatesigningrequest_cert_length gauge
3939
`
4040
cases := []generateMetricsTestCase{

internal/store/configmap.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"k8s.io/apimachinery/pkg/watch"
2626
clientset "k8s.io/client-go/kubernetes"
2727
"k8s.io/client-go/tools/cache"
28+
basemetrics "k8s.io/component-base/metrics"
2829

2930
"k8s.io/kube-state-metrics/v2/pkg/metric"
3031
generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator"
@@ -54,10 +55,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
5455
}
5556
}),
5657
),
57-
*generator.NewFamilyGenerator(
58+
*generator.NewFamilyGeneratorWithStability(
5859
"kube_configmap_labels",
5960
"Kubernetes labels converted to Prometheus labels.",
6061
metric.Gauge,
62+
basemetrics.STABLE,
6163
"",
6264
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
6365
labelKeys, labelValues := createPrometheusLabelKeysValues("label", c.Labels, allowLabelsList)
@@ -72,10 +74,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
7274
}
7375
}),
7476
),
75-
*generator.NewFamilyGenerator(
77+
*generator.NewFamilyGeneratorWithStability(
7678
"kube_configmap_info",
7779
"Information about configmap.",
7880
metric.Gauge,
81+
basemetrics.STABLE,
7982
"",
8083
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
8184
return &metric.Family{
@@ -87,10 +90,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
8790
}
8891
}),
8992
),
90-
*generator.NewFamilyGenerator(
93+
*generator.NewFamilyGeneratorWithStability(
9194
"kube_configmap_created",
9295
"Unix creation timestamp",
9396
metric.Gauge,
97+
basemetrics.STABLE,
9498
"",
9599
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
96100
ms := []*metric.Metric{}

internal/store/configmap_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func TestConfigMapStore(t *testing.T) {
5454
},
5555
Want: `
5656
# HELP kube_configmap_annotations Kubernetes annotations converted to Prometheus labels.
57-
# HELP kube_configmap_labels Kubernetes labels converted to Prometheus labels.
58-
# HELP kube_configmap_info Information about configmap.
57+
# HELP kube_configmap_labels [STABLE] Kubernetes labels converted to Prometheus labels.
58+
# HELP kube_configmap_info [STABLE] Information about configmap.
5959
# HELP kube_configmap_metadata_resource_version Resource version representing a specific version of the configmap.
6060
# TYPE kube_configmap_annotations gauge
6161
# TYPE kube_configmap_labels gauge
@@ -82,8 +82,8 @@ func TestConfigMapStore(t *testing.T) {
8282
},
8383
},
8484
Want: `
85-
# HELP kube_configmap_created Unix creation timestamp
86-
# HELP kube_configmap_info Information about configmap.
85+
# HELP kube_configmap_created [STABLE] Unix creation timestamp
86+
# HELP kube_configmap_info [STABLE] Information about configmap.
8787
# HELP kube_configmap_metadata_resource_version Resource version representing a specific version of the configmap.
8888
# TYPE kube_configmap_created gauge
8989
# TYPE kube_configmap_info gauge

internal/store/cronjob.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/watch"
3030
clientset "k8s.io/client-go/kubernetes"
3131
"k8s.io/client-go/tools/cache"
32+
basemetrics "k8s.io/component-base/metrics"
3233

3334
"k8s.io/kube-state-metrics/v2/pkg/metric"
3435
generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator"
@@ -62,10 +63,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
6263
}
6364
}),
6465
),
65-
*generator.NewFamilyGenerator(
66+
*generator.NewFamilyGeneratorWithStability(
6667
descCronJobLabelsName,
6768
descCronJobLabelsHelp,
6869
metric.Gauge,
70+
basemetrics.STABLE,
6971
"",
7072
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
7173
labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList)
@@ -80,10 +82,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
8082
}
8183
}),
8284
),
83-
*generator.NewFamilyGenerator(
85+
*generator.NewFamilyGeneratorWithStability(
8486
"kube_cronjob_info",
8587
"Info about cronjob.",
8688
metric.Gauge,
89+
basemetrics.STABLE,
8790
"",
8891
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
8992
return &metric.Family{
@@ -97,10 +100,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
97100
}
98101
}),
99102
),
100-
*generator.NewFamilyGenerator(
103+
*generator.NewFamilyGeneratorWithStability(
101104
"kube_cronjob_created",
102105
"Unix creation timestamp",
103106
metric.Gauge,
107+
basemetrics.STABLE,
104108
"",
105109
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
106110
ms := []*metric.Metric{}
@@ -117,10 +121,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
117121
}
118122
}),
119123
),
120-
*generator.NewFamilyGenerator(
124+
*generator.NewFamilyGeneratorWithStability(
121125
"kube_cronjob_status_active",
122126
"Active holds pointers to currently running jobs.",
123127
metric.Gauge,
128+
basemetrics.STABLE,
124129
"",
125130
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
126131
return &metric.Family{
@@ -134,10 +139,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
134139
}
135140
}),
136141
),
137-
*generator.NewFamilyGenerator(
142+
*generator.NewFamilyGeneratorWithStability(
138143
"kube_cronjob_status_last_schedule_time",
139144
"LastScheduleTime keeps information of when was the last time the job was successfully scheduled.",
140145
metric.Gauge,
146+
basemetrics.STABLE,
141147
"",
142148
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
143149
ms := []*metric.Metric{}
@@ -176,10 +182,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
176182
}
177183
}),
178184
),
179-
*generator.NewFamilyGenerator(
185+
*generator.NewFamilyGeneratorWithStability(
180186
"kube_cronjob_spec_suspend",
181187
"Suspend flag tells the controller to suspend subsequent executions.",
182188
metric.Gauge,
189+
basemetrics.STABLE,
183190
"",
184191
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
185192
ms := []*metric.Metric{}
@@ -197,10 +204,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
197204
}
198205
}),
199206
),
200-
*generator.NewFamilyGenerator(
207+
*generator.NewFamilyGeneratorWithStability(
201208
"kube_cronjob_spec_starting_deadline_seconds",
202209
"Deadline in seconds for starting the job if it misses scheduled time for any reason.",
203210
metric.Gauge,
211+
basemetrics.STABLE,
204212
"",
205213
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
206214
ms := []*metric.Metric{}
@@ -219,10 +227,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
219227
}
220228
}),
221229
),
222-
*generator.NewFamilyGenerator(
230+
*generator.NewFamilyGeneratorWithStability(
223231
"kube_cronjob_next_schedule_time",
224232
"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.",
225233
metric.Gauge,
234+
basemetrics.STABLE,
226235
"",
227236
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
228237
ms := []*metric.Metric{}
@@ -244,10 +253,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
244253
}
245254
}),
246255
),
247-
*generator.NewFamilyGenerator(
256+
*generator.NewFamilyGeneratorWithStability(
248257
"kube_cronjob_metadata_resource_version",
249258
"Resource version representing a specific version of the cronjob.",
250259
metric.Gauge,
260+
basemetrics.STABLE,
251261
"",
252262
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
253263
return &metric.Family{

internal/store/cronjob_test.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ func TestCronJobStore(t *testing.T) {
135135
},
136136
},
137137
Want: `
138-
# HELP kube_cronjob_created Unix creation timestamp
139-
# HELP kube_cronjob_info Info about cronjob.
138+
# HELP kube_cronjob_created [STABLE] Unix creation timestamp
139+
# HELP kube_cronjob_info [STABLE] Info about cronjob.
140140
# HELP kube_cronjob_annotations Kubernetes annotations converted to Prometheus labels.
141-
# HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels.
142-
# 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.
141+
# HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels.
142+
# 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.
143143
# HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved.
144-
# HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason.
144+
# HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason.
145145
# HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved.
146-
# HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions.
147-
# HELP kube_cronjob_status_active Active holds pointers to currently running jobs.
148-
# HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob.
149-
# HELP kube_cronjob_status_last_schedule_time LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
146+
# HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions.
147+
# HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs.
148+
# HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob.
149+
# HELP kube_cronjob_status_last_schedule_time [STABLE] LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
150150
# TYPE kube_cronjob_created gauge
151151
# TYPE kube_cronjob_info gauge
152152
# TYPE kube_cronjob_annotations gauge
@@ -212,16 +212,16 @@ func TestCronJobStore(t *testing.T) {
212212
},
213213
},
214214
Want: `
215-
# HELP kube_cronjob_created Unix creation timestamp
216-
# HELP kube_cronjob_info Info about cronjob.
217-
# HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels.
215+
# HELP kube_cronjob_created [STABLE] Unix creation timestamp
216+
# HELP kube_cronjob_info [STABLE] Info about cronjob.
217+
# HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels.
218218
# HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved.
219-
# HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason.
219+
# HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason.
220220
# HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved.
221-
# HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions.
222-
# HELP kube_cronjob_status_active Active holds pointers to currently running jobs.
223-
# HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob.
224-
# HELP kube_cronjob_status_last_schedule_time LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
221+
# HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions.
222+
# HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs.
223+
# HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob.
224+
# HELP kube_cronjob_status_last_schedule_time [STABLE] LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
225225
# HELP kube_cronjob_status_last_successful_time LastSuccessfulTime keeps information of when was the last time the job was completed successfully.
226226
# TYPE kube_cronjob_created gauge
227227
# TYPE kube_cronjob_info gauge
@@ -272,16 +272,16 @@ func TestCronJobStore(t *testing.T) {
272272
},
273273
},
274274
Want: `
275-
# HELP kube_cronjob_created Unix creation timestamp
276-
# HELP kube_cronjob_info Info about cronjob.
277-
# HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels.
275+
# HELP kube_cronjob_created [STABLE] Unix creation timestamp
276+
# HELP kube_cronjob_info [STABLE] Info about cronjob.
277+
# HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels.
278278
# HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved.
279-
# HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason.
279+
# HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason.
280280
# HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved.
281-
# HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions.
282-
# HELP kube_cronjob_status_active Active holds pointers to currently running jobs.
283-
# HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob.
284-
# HELP kube_cronjob_status_last_schedule_time LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
281+
# HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions.
282+
# HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs.
283+
# HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob.
284+
# HELP kube_cronjob_status_last_schedule_time [STABLE] LastScheduleTime keeps information of when was the last time the job was successfully scheduled.
285285
# HELP kube_cronjob_status_last_successful_time LastSuccessfulTime keeps information of when was the last time the job was completed successfully.
286286
# TYPE kube_cronjob_created gauge
287287
# TYPE kube_cronjob_info gauge
@@ -334,17 +334,17 @@ func TestCronJobStore(t *testing.T) {
334334
},
335335
},
336336
Want: `
337-
# HELP kube_cronjob_created Unix creation timestamp
338-
# HELP kube_cronjob_info Info about cronjob.
339-
# HELP kube_cronjob_labels Kubernetes labels converted to Prometheus labels.
340-
# 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.
337+
# HELP kube_cronjob_created [STABLE] Unix creation timestamp
338+
# HELP kube_cronjob_info [STABLE] Info about cronjob.
339+
# HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels.
340+
# 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.
341341
# HELP kube_cronjob_spec_failed_job_history_limit Failed job history limit tells the controller how many failed jobs should be preserved.
342-
# HELP kube_cronjob_spec_starting_deadline_seconds Deadline in seconds for starting the job if it misses scheduled time for any reason.
342+
# HELP kube_cronjob_spec_starting_deadline_seconds [STABLE] Deadline in seconds for starting the job if it misses scheduled time for any reason.
343343
# HELP kube_cronjob_spec_successful_job_history_limit Successful job history limit tells the controller how many completed jobs should be preserved.
344-
# HELP kube_cronjob_spec_suspend Suspend flag tells the controller to suspend subsequent executions.
345-
# HELP kube_cronjob_status_active Active holds pointers to currently running jobs.
344+
# HELP kube_cronjob_spec_suspend [STABLE] Suspend flag tells the controller to suspend subsequent executions.
345+
# HELP kube_cronjob_status_active [STABLE] Active holds pointers to currently running jobs.
346346
# HELP kube_cronjob_status_last_successful_time LastSuccessfulTime keeps information of when was the last time the job was completed successfully.
347-
# HELP kube_cronjob_metadata_resource_version Resource version representing a specific version of the cronjob.
347+
# HELP kube_cronjob_metadata_resource_version [STABLE] Resource version representing a specific version of the cronjob.
348348
# TYPE kube_cronjob_created gauge
349349
# TYPE kube_cronjob_info gauge
350350
# TYPE kube_cronjob_labels gauge

0 commit comments

Comments
 (0)