diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4da46a4f5..9b04cbe99 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,7 @@ * FEATURE: vmalert: add `-datasource.appendTypePrefix` command-line option for querying both Prometheus and Graphite datasource in cluster version of VictoriaMetrics. See [these docs](https://victoriametrics.github.io/vmalert.html#graphite) for details. * FEATURE: vmauth: add ability to route requests from a single user to multiple destinations depending on the requested paths. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1064 * FEATURE: remove dependency on external programs such as `cat`, `grep` and `cut` when detecting cpu and memory limits inside Docker or LXC container. +* FEATURE: vmagent: add `__meta_kubernetes_endpoints_label_*`, `__meta_kubernetes_endpoints_labelpresent_*`, `__meta_kubernetes_endpoints_annotation_*` and `__meta_kubernetes_endpoints_annotationpresent_*` labels for `role: endpoints` in Kubernetes service discovery. These labels where added in Prometheus 2.25. * BUGFIX: properly convert regexp tag filters containing escaped dots to non-regexp tag filters. For example, `{foo=~"bar\.baz"}` should be converted to `{foo="bar.baz"}`. Previously it was incorrectly converted to `{foo="bar\.baz"}`, which could result in missing time series for this tag filter. * BUGFIX: do not spam error logs when discovering Docker Swarm targets without dedicated IP. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1028 . diff --git a/lib/promscrape/discovery/kubernetes/endpoints.go b/lib/promscrape/discovery/kubernetes/endpoints.go index edd538746..6f95a2a9d 100644 --- a/lib/promscrape/discovery/kubernetes/endpoints.go +++ b/lib/promscrape/discovery/kubernetes/endpoints.go @@ -183,6 +183,7 @@ func getEndpointLabelsForAddressAndPort(podPortsSeen map[*Pod][]int, eps *Endpoi if svc != nil { svc.appendCommonLabels(m) } + eps.Metadata.registerLabelsAndAnnotations("__meta_kubernetes_endpoints", m) if ea.TargetRef.Kind != "Pod" || p == nil { return m } diff --git a/lib/promscrape/discovery/kubernetes/endpoints_test.go b/lib/promscrape/discovery/kubernetes/endpoints_test.go index 0decc0800..e5f0f4251 100644 --- a/lib/promscrape/discovery/kubernetes/endpoints_test.go +++ b/lib/promscrape/discovery/kubernetes/endpoints_test.go @@ -42,7 +42,13 @@ func TestParseEndpointsListSuccess(t *testing.T) { "selfLink": "/api/v1/namespaces/default/endpoints/kubernetes", "uid": "0972c7d9-c267-4b93-a090-a417eeb9b385", "resourceVersion": "150", - "creationTimestamp": "2020-03-16T20:44:25Z" + "creationTimestamp": "2020-03-16T20:44:25Z", + "labels": { + "foo": "bar" + }, + "annotations": { + "x": "y" + } }, "subsets": [ { @@ -91,15 +97,19 @@ func TestParseEndpointsListSuccess(t *testing.T) { expectedLabelss := [][]prompbmarshal.Label{ discoveryutils.GetSortedLabels(map[string]string{ "__address__": "172.17.0.2:8443", - "__meta_kubernetes_endpoint_address_target_kind": "Pod", - "__meta_kubernetes_endpoint_address_target_name": "coredns-6955765f44-lnp6t", - "__meta_kubernetes_endpoint_hostname": "aaa.bbb", - "__meta_kubernetes_endpoint_node_name": "foobar", - "__meta_kubernetes_endpoint_port_name": "https", - "__meta_kubernetes_endpoint_port_protocol": "TCP", - "__meta_kubernetes_endpoint_ready": "true", - "__meta_kubernetes_endpoints_name": "kubernetes", - "__meta_kubernetes_namespace": "default", + "__meta_kubernetes_endpoint_address_target_kind": "Pod", + "__meta_kubernetes_endpoint_address_target_name": "coredns-6955765f44-lnp6t", + "__meta_kubernetes_endpoint_hostname": "aaa.bbb", + "__meta_kubernetes_endpoint_node_name": "foobar", + "__meta_kubernetes_endpoint_port_name": "https", + "__meta_kubernetes_endpoint_port_protocol": "TCP", + "__meta_kubernetes_endpoint_ready": "true", + "__meta_kubernetes_endpoints_name": "kubernetes", + "__meta_kubernetes_endpoints_annotation_x": "y", + "__meta_kubernetes_endpoints_annotationpresent_x": "true", + "__meta_kubernetes_endpoints_label_foo": "bar", + "__meta_kubernetes_endpoints_labelpresent_foo": "true", + "__meta_kubernetes_namespace": "default", }), } if !reflect.DeepEqual(sortedLabelss, expectedLabelss) {