in internal/store/namespace.go [41:149]
func namespaceMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
return []generator.FamilyGenerator{
*generator.NewFamilyGenerator(
"kube_namespace_created",
"Unix creation timestamp",
metric.Gauge,
"",
wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family {
ms := []*metric.Metric{}
if !n.CreationTimestamp.IsZero() {
ms = append(ms, &metric.Metric{
Value: float64(n.CreationTimestamp.Unix()),
})
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
descNamespaceAnnotationsName,
descNamespaceAnnotationsHelp,
metric.Gauge,
"",
wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family {
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", n.Annotations, allowAnnotationsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: annotationKeys,
LabelValues: annotationValues,
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
descNamespaceLabelsName,
descNamespaceLabelsHelp,
metric.Gauge,
"",
wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family {
labelKeys, labelValues := createPrometheusLabelKeysValues("label", n.Labels, allowLabelsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: labelKeys,
LabelValues: labelValues,
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_namespace_status_phase",
"kubernetes namespace status phase.",
metric.Gauge,
"",
wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family {
ms := []*metric.Metric{
{
LabelValues: []string{string(v1.NamespaceActive)},
Value: boolFloat64(n.Status.Phase == v1.NamespaceActive),
},
{
LabelValues: []string{string(v1.NamespaceTerminating)},
Value: boolFloat64(n.Status.Phase == v1.NamespaceTerminating),
},
}
for _, metric := range ms {
metric.LabelKeys = []string{"phase"}
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_namespace_status_condition",
"The condition of a namespace.",
metric.Gauge,
"",
wrapNamespaceFunc(func(n *v1.Namespace) *metric.Family {
ms := make([]*metric.Metric, len(n.Status.Conditions)*len(conditionStatuses))
for i, c := range n.Status.Conditions {
conditionMetrics := addConditionMetrics(c.Status)
for j, m := range conditionMetrics {
metric := m
metric.LabelKeys = []string{"condition", "status"}
metric.LabelValues = append([]string{string(c.Type)}, metric.LabelValues...)
ms[i*len(conditionStatuses)+j] = metric
}
}
return &metric.Family{
Metrics: ms,
}
}),
),
}
}