diff --git a/docs/metrics/service/endpoint-metrics.md b/docs/metrics/service/endpoint-metrics.md index 4845988bdd..32f9791617 100644 --- a/docs/metrics/service/endpoint-metrics.md +++ b/docs/metrics/service/endpoint-metrics.md @@ -8,5 +8,5 @@ | kube_endpoint_info | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | | kube_endpoint_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`label_ENDPOINT_LABEL`=<ENDPOINT_LABEL> | STABLE | | kube_endpoint_created | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | -| kube_endpoint_ports | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number> | STABLE | -| kube_endpoint_address | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`ip`=<endpoint-ip>
`ready`=<true if available, false if unavailalbe> | STABLE | +| kube_endpoint_ports | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number> | STABLE (Deprecated from 2.14.0) | +| kube_endpoint_address | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`ip`=<endpoint-ip>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number>`ready`=<true if available, false if unavailalbe> | STABLE | diff --git a/internal/store/endpoint.go b/internal/store/endpoint.go index 482eb98e2c..7c642feb43 100644 --- a/internal/store/endpoint.go +++ b/internal/store/endpoint.go @@ -173,19 +173,24 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} for _, s := range e.Subsets { - for _, available := range s.Addresses { - ms = append(ms, &metric.Metric{ - LabelValues: []string{available.IP, "true"}, - LabelKeys: []string{"ip", "ready"}, - Value: 1, - }) - } - for _, notReadyAddresses := range s.NotReadyAddresses { - ms = append(ms, &metric.Metric{ - LabelValues: []string{notReadyAddresses.IP, "false"}, - LabelKeys: []string{"ip", "ready"}, - Value: 1, - }) + for _, port := range s.Ports { + labelValues := []string{port.Name, string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)} + labelKeys := []string{"port_name", "port_protocol", "port_number"} + + for _, available := range s.Addresses { + ms = append(ms, &metric.Metric{ + LabelValues: append(labelValues, available.IP, "true"), + LabelKeys: append(labelKeys, "ip", "ready"), + Value: 1, + }) + } + for _, notReadyAddresses := range s.NotReadyAddresses { + ms = append(ms, &metric.Metric{ + LabelValues: append(labelValues, notReadyAddresses.IP, "false"), + LabelKeys: append(labelKeys, "ip", "ready"), + Value: 1, + }) + } } } return &metric.Family{ @@ -195,7 +200,7 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge ), *generator.NewFamilyGeneratorWithStability( "kube_endpoint_ports", - "Information about the Endpoint ports.", + "(Deprecated from 2.14.0) Information about the Endpoint ports.", metric.Gauge, basemetrics.STABLE, "",