in internal/store/verticalpodautoscaler.go [45:247]
func vpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
return []generator.FamilyGenerator{
*generator.NewFamilyGenerator(
descVerticalPodAutoscalerAnnotationsName,
descVerticalPodAutoscalerAnnotationsHelp,
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", a.Annotations, allowAnnotationsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: annotationKeys,
LabelValues: annotationValues,
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
descVerticalPodAutoscalerLabelsName,
descVerticalPodAutoscalerLabelsHelp,
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
labelKeys, labelValues := createPrometheusLabelKeysValues("label", a.Labels, allowLabelsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: labelKeys,
LabelValues: labelValues,
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_spec_updatepolicy_updatemode",
"Update mode of the VerticalPodAutoscaler.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Spec.UpdatePolicy == nil || a.Spec.UpdatePolicy.UpdateMode == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, mode := range []autoscaling.UpdateMode{
autoscaling.UpdateModeOff,
autoscaling.UpdateModeInitial,
autoscaling.UpdateModeRecreate,
autoscaling.UpdateModeAuto,
} {
var v float64
if *a.Spec.UpdatePolicy.UpdateMode == mode {
v = 1
} else {
v = 0
}
ms = append(ms, &metric.Metric{
LabelKeys: []string{"update_mode"},
LabelValues: []string{string(mode)},
Value: v,
})
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_spec_resourcepolicy_container_policies_minallowed",
"Minimum resources the VerticalPodAutoscaler can set for containers matching the name.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Spec.ResourcePolicy == nil || a.Spec.ResourcePolicy.ContainerPolicies == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, c := range a.Spec.ResourcePolicy.ContainerPolicies {
ms = append(ms, vpaResourcesToMetrics(c.ContainerName, c.MinAllowed)...)
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_spec_resourcepolicy_container_policies_maxallowed",
"Maximum resources the VerticalPodAutoscaler can set for containers matching the name.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Spec.ResourcePolicy == nil || a.Spec.ResourcePolicy.ContainerPolicies == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, c := range a.Spec.ResourcePolicy.ContainerPolicies {
ms = append(ms, vpaResourcesToMetrics(c.ContainerName, c.MaxAllowed)...)
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_status_recommendation_containerrecommendations_lowerbound",
"Minimum resources the container can use before the VerticalPodAutoscaler updater evicts it.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Status.Recommendation == nil || a.Status.Recommendation.ContainerRecommendations == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, c := range a.Status.Recommendation.ContainerRecommendations {
ms = append(ms, vpaResourcesToMetrics(c.ContainerName, c.LowerBound)...)
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_status_recommendation_containerrecommendations_upperbound",
"Maximum resources the container can use before the VerticalPodAutoscaler updater evicts it.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Status.Recommendation == nil || a.Status.Recommendation.ContainerRecommendations == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, c := range a.Status.Recommendation.ContainerRecommendations {
ms = append(ms, vpaResourcesToMetrics(c.ContainerName, c.UpperBound)...)
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_status_recommendation_containerrecommendations_target",
"Target resources the VerticalPodAutoscaler recommends for the container.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Status.Recommendation == nil || a.Status.Recommendation.ContainerRecommendations == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, c := range a.Status.Recommendation.ContainerRecommendations {
ms = append(ms, vpaResourcesToMetrics(c.ContainerName, c.Target)...)
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_verticalpodautoscaler_status_recommendation_containerrecommendations_uncappedtarget",
"Target resources the VerticalPodAutoscaler recommends for the container ignoring bounds.",
metric.Gauge,
"",
wrapVPAFunc(func(a *autoscaling.VerticalPodAutoscaler) *metric.Family {
ms := []*metric.Metric{}
if a.Status.Recommendation == nil || a.Status.Recommendation.ContainerRecommendations == nil {
return &metric.Family{
Metrics: ms,
}
}
for _, c := range a.Status.Recommendation.ContainerRecommendations {
ms = append(ms, vpaResourcesToMetrics(c.ContainerName, c.UncappedTarget)...)
}
return &metric.Family{
Metrics: ms,
}
}),
),
}
}