diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 40293bc30..8da310438 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -17,6 +17,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): fix potential panic in [multi-level cluster setup](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multi-level-cluster-setup) when top-level `vmselect` is configured with `-replicationFactor` bigger than 1. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2961). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly handle custom `endpoint` value in [ec2_sd_configs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config). It was ignored since [v1.77.0](https://docs.victoriametrics.com/CHANGELOG.html#v1770) because of a bug in the implementation of [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1287). +* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): add missing `__meta_kubernetes_ingress_class_name` meta-label for `role: ingress` service discovery in Kubernetes. See [this commit from Prometheus](https://github.com/prometheus/prometheus/commit/7e65ad3e432bd2837c17e3e63e85dcbcc30f4a8a). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): allow stale responses from Consul service discovery (aka [consul_sd_configs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config)) by default in the same way as Prometheus does. This should reduce load on Consul when discovering big number of targets. Stale responses can be disabled by specifying `allow_stale: false` option in `consul_sd_config`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2940). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): [dockerswarm_sd_configs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dockerswarm_sd_config): properly set `__meta_dockerswarm_container_label_*` labels instead of `__meta_dockerswarm_task_label_*` labels as Prometheus does. See [this issue](https://github.com/prometheus/prometheus/issues/9187). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): set `up` metric to `0` for partial scrapes in [stream parsing mode](https://docs.victoriametrics.com/vmagent.html#stream-parsing-mode). Previously the `up` metric was set to `1` when at least a single metric has been scraped before the error. This aligns the behaviour of `vmselect` with Prometheus. diff --git a/lib/promscrape/discovery/kubernetes/ingress.go b/lib/promscrape/discovery/kubernetes/ingress.go index 71b398bd4..7247c68ac 100644 --- a/lib/promscrape/discovery/kubernetes/ingress.go +++ b/lib/promscrape/discovery/kubernetes/ingress.go @@ -52,8 +52,9 @@ type Ingress struct { // // See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#ingressspec-v1-networking-k8s-io type IngressSpec struct { - TLS []IngressTLS `json:"tls"` - Rules []IngressRule + TLS []IngressTLS `json:"tls"` + Rules []IngressRule + IngressClassName string } // IngressTLS represents ingress TLS spec in k8s. @@ -130,12 +131,13 @@ func matchesHostPattern(pattern, host string) bool { func getLabelsForIngressPath(ig *Ingress, scheme, host, path string) map[string]string { m := map[string]string{ - "__address__": host, - "__meta_kubernetes_namespace": ig.Metadata.Namespace, - "__meta_kubernetes_ingress_name": ig.Metadata.Name, - "__meta_kubernetes_ingress_scheme": scheme, - "__meta_kubernetes_ingress_host": host, - "__meta_kubernetes_ingress_path": path, + "__address__": host, + "__meta_kubernetes_namespace": ig.Metadata.Namespace, + "__meta_kubernetes_ingress_name": ig.Metadata.Name, + "__meta_kubernetes_ingress_scheme": scheme, + "__meta_kubernetes_ingress_host": host, + "__meta_kubernetes_ingress_path": path, + "__meta_kubernetes_ingress_class_name": ig.Spec.IngressClassName, } ig.Metadata.registerLabelsAndAnnotations("__meta_kubernetes_ingress", m) return m diff --git a/lib/promscrape/discovery/kubernetes/ingress_test.go b/lib/promscrape/discovery/kubernetes/ingress_test.go index 87a734d05..004c9abd1 100644 --- a/lib/promscrape/discovery/kubernetes/ingress_test.go +++ b/lib/promscrape/discovery/kubernetes/ingress_test.go @@ -78,7 +78,8 @@ func TestParseIngressListSuccess(t *testing.T) { { "host": "foobar" } - ] + ], + "ingressClassName": "foo-class" }, "status": { "loadBalancer": { @@ -107,11 +108,12 @@ func TestParseIngressListSuccess(t *testing.T) { "__address__": "foobar", "__meta_kubernetes_ingress_annotation_kubectl_kubernetes_io_last_applied_configuration": `{"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"name":"test-ingress","namespace":"default"},"spec":{"backend":{"serviceName":"testsvc","servicePort":80}}}` + "\n", "__meta_kubernetes_ingress_annotationpresent_kubectl_kubernetes_io_last_applied_configuration": "true", - "__meta_kubernetes_ingress_host": "foobar", - "__meta_kubernetes_ingress_name": "test-ingress", - "__meta_kubernetes_ingress_path": "/", - "__meta_kubernetes_ingress_scheme": "http", - "__meta_kubernetes_namespace": "default", + "__meta_kubernetes_ingress_host": "foobar", + "__meta_kubernetes_ingress_name": "test-ingress", + "__meta_kubernetes_ingress_path": "/", + "__meta_kubernetes_ingress_scheme": "http", + "__meta_kubernetes_ingress_class_name": "foo-class", + "__meta_kubernetes_namespace": "default", }), } if !areEqualLabelss(sortedLabelss, expectedLabelss) {