in internal/store/endpoint.go [42:176]
func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
return []generator.FamilyGenerator{
*generator.NewFamilyGenerator(
"kube_endpoint_info",
"Information about endpoint.",
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_endpoint_created",
"Unix creation timestamp",
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
ms := []*metric.Metric{}
if !e.CreationTimestamp.IsZero() {
ms = append(ms, &metric.Metric{
Value: float64(e.CreationTimestamp.Unix()),
})
}
return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
descEndpointAnnotationsName,
descEndpointAnnotationsHelp,
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", e.Annotations, allowAnnotationsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: annotationKeys,
LabelValues: annotationValues,
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
descEndpointLabelsName,
descEndpointLabelsHelp,
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
labelKeys, labelValues := createPrometheusLabelKeysValues("label", e.Labels, allowLabelsList)
return &metric.Family{
Metrics: []*metric.Metric{
{
LabelKeys: labelKeys,
LabelValues: labelValues,
Value: 1,
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_endpoint_address_available",
"Number of addresses available in endpoint.",
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
var available int
for _, s := range e.Subsets {
available += len(s.Addresses) * len(s.Ports)
}
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(available),
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_endpoint_address_not_ready",
"Number of addresses not ready in endpoint",
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
var notReady int
for _, s := range e.Subsets {
notReady += len(s.NotReadyAddresses) * len(s.Ports)
}
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(notReady),
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_endpoint_ports",
"Information about the Endpoint ports.",
metric.Gauge,
"",
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
ms := []*metric.Metric{}
for _, s := range e.Subsets {
for _, port := range s.Ports {
ms = append(ms, &metric.Metric{
LabelValues: []string{port.Name, string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)},
LabelKeys: []string{"port_name", "port_protocol", "port_number"},
Value: 1,
})
}
}
return &metric.Family{
Metrics: ms,
}
}),
),
}
}