@@ -44,17 +44,15 @@ func (m metricTargetType) String() string {
44
44
}
45
45
46
46
var (
47
- descHorizontalPodAutoscalerAnnotationsName = "kube_horizontalpodautoscaler_annotations"
48
- descHorizontalPodAutoscalerAnnotationsHelp = "Kubernetes annotations converted to Prometheus labels."
49
- descHorizontalPodAutoscalerLabelsName = "kube_horizontalpodautoscaler_labels"
50
- descHorizontalPodAutoscalerLabelsHelp = "Kubernetes labels converted to Prometheus labels."
51
47
descHorizontalPodAutoscalerLabelsDefaultLabels = []string {"namespace" , "horizontalpodautoscaler" }
52
48
53
49
targetMetricLabels = []string {"metric_name" , "metric_target_type" }
54
50
)
55
51
56
52
func hpaMetricFamilies (allowAnnotationsList , allowLabelsList []string ) []generator.FamilyGenerator {
57
- return []generator.FamilyGenerator {
53
+ metadataFamilies := createMetadataMetricFamiliesGenerator (allowAnnotationsList , allowLabelsList , descHorizontalPodAutoscalerLabelsDefaultLabels , "kube_horizontalpodautoscaler" )
54
+
55
+ return append (metadataFamilies ,
58
56
createHPAInfo (),
59
57
createHPAMetaDataGeneration (),
60
58
createHPASpecMaxReplicas (),
@@ -63,12 +61,8 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
63
61
createHPAStatusTargetMetric (),
64
62
createHPAStatusCurrentReplicas (),
65
63
createHPAStatusDesiredReplicas (),
66
- createHPAAnnotations (allowAnnotationsList ),
67
- createHPALabels (allowLabelsList ),
68
64
createHPAStatusCondition (),
69
- createHPACreated (),
70
- createHPADeletionTimestamp (),
71
- }
65
+ )
72
66
}
73
67
74
68
func wrapHPAFunc (f func (* autoscaling.HorizontalPodAutoscaler ) * metric.Family ) func (interface {}) * metric.Family {
@@ -338,56 +332,6 @@ func createHPAStatusDesiredReplicas() generator.FamilyGenerator {
338
332
)
339
333
}
340
334
341
- func createHPAAnnotations (allowAnnotationsList []string ) generator.FamilyGenerator {
342
- return * generator .NewFamilyGeneratorWithStability (
343
- descHorizontalPodAutoscalerAnnotationsName ,
344
- descHorizontalPodAutoscalerAnnotationsHelp ,
345
- metric .Gauge ,
346
- basemetrics .ALPHA ,
347
- "" ,
348
- wrapHPAFunc (func (a * autoscaling.HorizontalPodAutoscaler ) * metric.Family {
349
- if len (allowAnnotationsList ) == 0 {
350
- return & metric.Family {}
351
- }
352
- annotationKeys , annotationValues := createPrometheusLabelKeysValues ("annotation" , a .Annotations , allowAnnotationsList )
353
- return & metric.Family {
354
- Metrics : []* metric.Metric {
355
- {
356
- LabelKeys : annotationKeys ,
357
- LabelValues : annotationValues ,
358
- Value : 1 ,
359
- },
360
- },
361
- }
362
- }),
363
- )
364
- }
365
-
366
- func createHPALabels (allowLabelsList []string ) generator.FamilyGenerator {
367
- return * generator .NewFamilyGeneratorWithStability (
368
- descHorizontalPodAutoscalerLabelsName ,
369
- descHorizontalPodAutoscalerLabelsHelp ,
370
- metric .Gauge ,
371
- basemetrics .STABLE ,
372
- "" ,
373
- wrapHPAFunc (func (a * autoscaling.HorizontalPodAutoscaler ) * metric.Family {
374
- if len (allowLabelsList ) == 0 {
375
- return & metric.Family {}
376
- }
377
- labelKeys , labelValues := createPrometheusLabelKeysValues ("label" , a .Labels , allowLabelsList )
378
- return & metric.Family {
379
- Metrics : []* metric.Metric {
380
- {
381
- LabelKeys : labelKeys ,
382
- LabelValues : labelValues ,
383
- Value : 1 ,
384
- },
385
- },
386
- }
387
- }),
388
- )
389
- }
390
-
391
335
func createHPAStatusCondition () generator.FamilyGenerator {
392
336
return * generator .NewFamilyGeneratorWithStability (
393
337
"kube_horizontalpodautoscaler_status_condition" ,
@@ -415,49 +359,3 @@ func createHPAStatusCondition() generator.FamilyGenerator {
415
359
}),
416
360
)
417
361
}
418
-
419
- func createHPACreated () generator.FamilyGenerator {
420
- return * generator .NewFamilyGeneratorWithStability (
421
- "kube_horizontalpodautoscaler_created" ,
422
- "Unix creation timestamp" ,
423
- metric .Gauge ,
424
- basemetrics .ALPHA ,
425
- "" ,
426
- wrapHPAFunc (func (a * autoscaling.HorizontalPodAutoscaler ) * metric.Family {
427
- ms := []* metric.Metric {}
428
-
429
- if ! a .CreationTimestamp .IsZero () {
430
- ms = append (ms , & metric.Metric {
431
- Value : float64 (a .CreationTimestamp .Unix ()),
432
- })
433
- }
434
-
435
- return & metric.Family {
436
- Metrics : ms ,
437
- }
438
- }),
439
- )
440
- }
441
-
442
- func createHPADeletionTimestamp () generator.FamilyGenerator {
443
- return * generator .NewFamilyGeneratorWithStability (
444
- "kube_horizontalpodautoscaler_deletion_timestamp" ,
445
- "Unix deletion timestamp" ,
446
- metric .Gauge ,
447
- basemetrics .ALPHA ,
448
- "" ,
449
- wrapHPAFunc (func (a * autoscaling.HorizontalPodAutoscaler ) * metric.Family {
450
- ms := []* metric.Metric {}
451
-
452
- if ! a .DeletionTimestamp .IsZero () {
453
- ms = append (ms , & metric.Metric {
454
- Value : float64 (a .DeletionTimestamp .Unix ()),
455
- })
456
- }
457
-
458
- return & metric.Family {
459
- Metrics : ms ,
460
- }
461
- }),
462
- )
463
- }
0 commit comments