mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
lib/promscrape/discovery/kubernetes: log a warning if role: endpoints
discovers more than 1000 targets per a single endpoint
In this case `role: endpointslice` must be used instead. See the following references: * https://kubernetes.io/docs/reference/labels-annotations-taints/#endpoints-kubernetes-io-over-capacity * https://github.com/kubernetes/kubernetes/pull/99975 * https://github.com/prometheus/prometheus/issues/7572#issuecomment-934779398
This commit is contained in:
parent
0d48b89afe
commit
3408a05d12
2 changed files with 19 additions and 0 deletions
lib/promscrape
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -103,6 +104,14 @@ func (eps *Endpoints) getTargetLabels(gw *groupWatcher) []map[string]string {
|
||||||
ms = appendEndpointLabelsForAddresses(ms, gw, podPortsSeen, eps, ess.NotReadyAddresses, epp, svc, "false")
|
ms = appendEndpointLabelsForAddresses(ms, gw, podPortsSeen, eps, ess.NotReadyAddresses, epp, svc, "false")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// See https://kubernetes.io/docs/reference/labels-annotations-taints/#endpoints-kubernetes-io-over-capacity
|
||||||
|
// and https://github.com/kubernetes/kubernetes/pull/99975
|
||||||
|
switch eps.Metadata.Annotations.GetByName("endpoints.kubernetes.io/over-capacity") {
|
||||||
|
case "truncated":
|
||||||
|
logger.Warnf(`the number of targets for "role: endpoints" %q exceeds 1000 and has been truncated; please use "role: endpointslice" instead`, eps.Metadata.key())
|
||||||
|
case "warning":
|
||||||
|
logger.Warnf(`the number of targets for "role: endpoints" %q exceeds 1000 and will be truncated in the next k8s releases; please use "role: endpointslice" instead`, eps.Metadata.key())
|
||||||
|
}
|
||||||
|
|
||||||
// Append labels for skipped ports on seen pods.
|
// Append labels for skipped ports on seen pods.
|
||||||
portSeen := func(port int, ports []int) bool {
|
portSeen := func(port int, ports []int) bool {
|
||||||
|
|
|
@ -33,6 +33,16 @@ func JoinHostPort(host string, port int) string {
|
||||||
// SortedLabels represents sorted labels.
|
// SortedLabels represents sorted labels.
|
||||||
type SortedLabels []prompbmarshal.Label
|
type SortedLabels []prompbmarshal.Label
|
||||||
|
|
||||||
|
// GetByName returns the label with the given name from sls.
|
||||||
|
func (sls *SortedLabels) GetByName(name string) string {
|
||||||
|
for _, lb := range *sls {
|
||||||
|
if lb.Name == name {
|
||||||
|
return lb.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals JSON from data.
|
// UnmarshalJSON unmarshals JSON from data.
|
||||||
func (sls *SortedLabels) UnmarshalJSON(data []byte) error {
|
func (sls *SortedLabels) UnmarshalJSON(data []byte) error {
|
||||||
var m map[string]string
|
var m map[string]string
|
||||||
|
|
Loading…
Reference in a new issue