prometheus-operator / kube-prometheus

Use Prometheus to monitor Kubernetes and applications running on Kubernetes
https://prometheus-operator.dev/
Apache License 2.0
6.74k stars 1.93k forks source link

kube-state-metrics cant get node label #1910

Open Ryu-Z opened 2 years ago

Ryu-Z commented 2 years ago

kube-state-metrics cant get node label

when i use kube-prometheus, i cant get node label from metrics: kube_node_labels{job="kube-state-metrics"}

imgae

image: k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.6.0

args

args:
  - --host=127.0.0.1
  - --port=8081
  - --telemetry-host=127.0.0.1
  - --telemetry-port=8082

clusterRole

...
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  - secrets
  - nodes
  - pods
  - services
  - serviceaccounts
  - resourcequotas
  - replicationcontrollers
  - limitranges
  - persistentvolumeclaims
  - persistentvolumes
  - namespaces
  - endpoints
  verbs:
  - list
  - watch
...

prometheus sql

kube_node_labels{job="kube-state-metrics"}

i got

...
kube_node_labels{node="ip-10-162-123-166.ap-northeast-1.compute.internal"} 1
...
lign0 commented 1 year ago

I also encountered the same problem. I could not get indicators such as label_alpha_eksctl_io_cluster_name. However, when I looked at the label of node in the cluster, all of them were available. For node, it seems that only node IP, instance, job, and container information can be obtained

lign0 commented 1 year ago

The current version is 0.11, which uses the default configuration of the project and only changes the node selector in namespace and env. Does anyone know the reason for this? I've been doing some research, kubernetes mentions Flags --metric-blacklist and --metric-whitelist were renamed to --metric-denylist and --metric-allowlist.--metric-labels-allowlist allows you to specify a list of Kubernetes labels that get turned into the dimensions of the kube_< resource-name> _labels metrics. By default, the metric contains only name and namespace labels. i have try the setting, but kube_node_labels still has the same label. Pls help

bigman3 commented 1 year ago

according to - https://github.com/kubernetes/kube-state-metrics/issues/1716 this is the correct value which seem to work

kube-state-metrics.extraArgs: - --metric-labels-allowlist=nodes=[*]

rgarcia89 commented 1 year ago

I would be interested in that to. These information are necessary to for example create a metric of which instance types are deployed and how many cores have been given to them.

I would expect labels to be shown like here: https://github.com/kubernetes/kube-state-metrics/issues/2009