mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/promscrape/discovery/kubernetes: add __meta_kubernetes_node_provider_id
label for discovered Kubernetes nodes in the same way as Prometheus does
See https://github.com/prometheus/prometheus/pull/9603
This commit is contained in:
parent
0f81ecd7df
commit
dd91759f1f
3 changed files with 22 additions and 10 deletions
|
@ -18,6 +18,7 @@ scrape_configs:
|
|||
namespaces:
|
||||
own_namespace: true
|
||||
```
|
||||
* FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): add `__meta_kubernetes_node_provider_id` label for discovered Kubernetes nodes in the same way as [Prometheus does](https://github.com/prometheus/prometheus/pull/9603).
|
||||
* FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): log error message when remote storage returns 400 or 409 http errors. This should simplify detection and debugging of this case. See [this issue](vmagent_remotewrite_packets_dropped_total).
|
||||
* FEATURE: [vmrestore](https://docs.victoriametrics.com/vmrestore.html): store `restore-in-progress` file in `-dst` directory while `vmrestore` is running. This file is automatically deleted when `vmrestore` is successfully finished. This helps detecting incompletely restored data on VictoriaMetrics start. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1958).
|
||||
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): print the last sample timestamp when the data migration is interrupted either by user or by error. This helps continuing the data migration from the interruption moment. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1236).
|
||||
|
|
|
@ -36,7 +36,7 @@ func parseNode(data []byte) (object, error) {
|
|||
|
||||
// NodeList represents NodeList from k8s API.
|
||||
//
|
||||
// See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#nodelist-v1-core
|
||||
// See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeList
|
||||
type NodeList struct {
|
||||
Metadata ListMeta
|
||||
Items []*Node
|
||||
|
@ -44,20 +44,28 @@ type NodeList struct {
|
|||
|
||||
// Node represents Node from k8s API.
|
||||
//
|
||||
// See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#node-v1-core
|
||||
// See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/
|
||||
type Node struct {
|
||||
Metadata ObjectMeta
|
||||
Status NodeStatus
|
||||
Spec NodeSpec
|
||||
}
|
||||
|
||||
// NodeStatus represents NodeStatus from k8s API.
|
||||
//
|
||||
// See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#nodestatus-v1-core
|
||||
// See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeStatus
|
||||
type NodeStatus struct {
|
||||
Addresses []NodeAddress
|
||||
DaemonEndpoints NodeDaemonEndpoints
|
||||
}
|
||||
|
||||
// NodeSpec represents NodeSpec from k8s API.
|
||||
//
|
||||
// See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeSpec
|
||||
type NodeSpec struct {
|
||||
ProviderID string
|
||||
}
|
||||
|
||||
// NodeAddress represents NodeAddress from k8s API.
|
||||
//
|
||||
// See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#nodeaddress-v1-core
|
||||
|
@ -84,9 +92,10 @@ func (n *Node) getTargetLabels(gw *groupWatcher) []map[string]string {
|
|||
}
|
||||
addr = discoveryutils.JoinHostPort(addr, n.Status.DaemonEndpoints.KubeletEndpoint.Port)
|
||||
m := map[string]string{
|
||||
"__address__": addr,
|
||||
"instance": n.Metadata.Name,
|
||||
"__meta_kubernetes_node_name": n.Metadata.Name,
|
||||
"__address__": addr,
|
||||
"instance": n.Metadata.Name,
|
||||
"__meta_kubernetes_node_name": n.Metadata.Name,
|
||||
"__meta_kubernetes_node_provider_id": n.Spec.ProviderID,
|
||||
}
|
||||
n.Metadata.registerLabelsAndAnnotations("__meta_kubernetes_node", m)
|
||||
addrTypesUsed := make(map[string]bool, len(n.Status.Addresses))
|
||||
|
|
|
@ -67,7 +67,8 @@ func TestParseNodeListSuccess(t *testing.T) {
|
|||
"podCIDR": "10.244.0.0/24",
|
||||
"podCIDRs": [
|
||||
"10.244.0.0/24"
|
||||
]
|
||||
],
|
||||
"providerID": "aws:///foo-bar/baz"
|
||||
},
|
||||
"status": {
|
||||
"capacity": {
|
||||
|
@ -243,9 +244,10 @@ func TestParseNodeListSuccess(t *testing.T) {
|
|||
sortedLabelss := getSortedLabelss(objectsByKey)
|
||||
expectedLabelss := [][]prompbmarshal.Label{
|
||||
discoveryutils.GetSortedLabels(map[string]string{
|
||||
"instance": "m01",
|
||||
"__address__": "172.17.0.2:10250",
|
||||
"__meta_kubernetes_node_name": "m01",
|
||||
"instance": "m01",
|
||||
"__address__": "172.17.0.2:10250",
|
||||
"__meta_kubernetes_node_name": "m01",
|
||||
"__meta_kubernetes_node_provider_id": "aws:///foo-bar/baz",
|
||||
|
||||
"__meta_kubernetes_node_label_beta_kubernetes_io_arch": "amd64",
|
||||
"__meta_kubernetes_node_label_beta_kubernetes_io_os": "linux",
|
||||
|
|
Loading…
Reference in a new issue