Skip to content

Commit

Permalink
feat(endpoints): Move ports into address metric
Browse files Browse the repository at this point in the history
This marks kube_endpoint_ports as deprecated

Fixes kubernetes#2408
  • Loading branch information
mrueg committed Sep 22, 2024
1 parent 3d969c5 commit 75a5d16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/metrics/service/endpoint-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
| kube_endpoint_info | Gauge | | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; | STABLE |
| kube_endpoint_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; <br> `label_ENDPOINT_LABEL`=&lt;ENDPOINT_LABEL&gt; | STABLE |
| kube_endpoint_created | Gauge | | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; | STABLE |
| kube_endpoint_ports | Gauge | | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; <br> `port_name`=&lt;endpoint-port-name&gt; <br> `port_protocol`=&lt;endpoint-port-protocol&gt; <br> `port_number`=&lt;endpoint-port-number&gt; | STABLE |
| kube_endpoint_address | Gauge | | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; <br> `ip`=&lt;endpoint-ip&gt; <br> `ready`=&lt;true if available, false if unavailalbe&gt; | STABLE |
| kube_endpoint_ports | Gauge | | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; <br> `port_name`=&lt;endpoint-port-name&gt; <br> `port_protocol`=&lt;endpoint-port-protocol&gt; <br> `port_number`=&lt;endpoint-port-number&gt; | STABLE (Deprecated from 2.14.0) |
| kube_endpoint_address | Gauge | | `endpoint`=&lt;endpoint-name&gt; <br> `namespace`=&lt;endpoint-namespace&gt; <br> `ip`=&lt;endpoint-ip&gt; <br> `port_name`=&lt;endpoint-port-name&gt; <br> `port_protocol`=&lt;endpoint-port-protocol&gt; <br> `port_number`=&lt;endpoint-port-number&gt;`ready`=&lt;true if available, false if unavailalbe&gt; | STABLE |
33 changes: 19 additions & 14 deletions internal/store/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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,
"",
Expand Down

0 comments on commit 75a5d16

Please sign in to comment.