How replicate label in prometheus metric

12/12/2018

The metric kube_pod_container_resource_requests_cpu_cores from kube-state-metrics comes with the labels:

kube_pod_container_resource_requests_cpu_cores{app="prometheus",chart="prometheus-8.1.0",component="kube-state-metrics",container="autoscaler",heritage="Tiller",instance="10.233.65.93:8080",job="kubernetes-service-endpoints",kubernetes_name="prometheus-kube-state-metrics",kubernetes_namespace="kube-system",kubernetes_node="k8st01",namespace="kube-system",node="k8snode",pod="kubedns-autoscaler-5db95c6cf5-cvqz4",release="prometheus"}

I want to make another label pod_name from pod , with the same values. In the end i want to have both pod="kubedns-autoscaler-5db95c6cf5-cvqz4" and pod_name="kubedns-autoscaler-5db95c6cf5-cvqz4"

I used the followimng

relabel_configs:
  - source_labels: [pod]
    target_label: pod_name

but it didn't work.

-- Tapxxor Stanijkis
kubernetes
prometheus

1 Answer

12/12/2018

Try to use metric_relabel_configs. Your config block would look something like this:

metric_relabel_configs:
  - source_labels: [pod]
    target_label: pod_name
-- Oliver
Source: StackOverflow