5

I have deployed application on kubernetes cluster and for monitoring using prometheus and grafana. For kubernetes pods monitoring using Grafana dashboard: Kubernetes cluster monitoring (via Prometheus) https://grafana.com/grafana/dashboards/315

I had imported the dashboard using id 315 and its reflecting without pod name and containers name instead getting pod_name . Can anyone pls help how can i get pod name and container name in dashboard.

enter image description here

enter image description here

enter image description here

3
  • Could you provide: 1. Screen of Settings > Variables 2.What version of Kubernetes are you using? I see that article was updated 2 yaers ago. 3. Your env is On-Perm or local? 4. Could you add your metrics query? Commented Jan 7, 2020 at 10:50
  • @PjoterS: Added screen setting of variable and kubernetes version is v1.17.0. This is my local environment project. This is not metrics query i have imported dashboard using grafana.com/grafana/dashboards/315 Commented Jan 7, 2020 at 12:13
  • thanks it works for me in Kubernetes 1.16 metrics labels like pod_name and container_name was removed. Instead of that you need to use pod and container. You can verify it here. Commented Mar 12, 2020 at 13:51

2 Answers 2

9

Provided tutorial was updated 2 years ago.

Current version of Kubernetes is 1.17. As per tags, tutorial was tested on Prometheus v. 1.3.0, Kubernetes v.1.4.0 and Grafana v.3.1.1 which are quite old at the moment.

In requirements you have statement:

Prometheus will use metrics provided by cAdvisor via kubelet service (runs on each node of Kubernetes cluster by default) and via kube-apiserver service only.

In Kubernetes 1.16 metrics labels like pod_name and container_name was removed. Instead of that you need to use pod and container. You can verify it here.

Any Prometheus queries that match pod_name and container_name labels (e.g. cadvisor or kubelet probe metrics) must be updated to use pod and container instead.

Please check this Github Thread about dashboard bug for more information.

Solution

Please change pod_name to pod in your query.

Sign up to request clarification or add additional context in comments.

5 Comments

No where i have manually mentioned the pod_name or container_name. I have imported the dashboard using grafana.com/grafana/dashboards/315. Can you pls help what need to be done. thanks
You are using K8s 1.17 which removed pod_name. In your variables you have $pod_name with labal_values(..... ,pod_name). You need change pod_name to pod in JSON Model. If you are using somewhere in this dashboard container_name you also need to change it to container.
I have downloaded the json file of grafana.com/grafana/dashboards/1621 and replaced the pod_name to pod and container_name to container in "expr" and "legendFormat" but still not working.
"expr": "sum (rate (container_cpu_usage_seconds_total{image!=\"\",name=~\"^k8s_.*\",kubernetes_io_hostname=~\"^$Node$\"}[1m])) by (pod)", "interval": "10s", "intervalFactor": 1, "legendFormat": "{{ pod }}", "metric": "container_cpu", "refId": "A", "step": 10
As I mentioned before, you used old version of Grafana, old Json file (last update 3 years ago.) and Kubernetes 1.17 which I dont think they are compatible. Please download latest version of Grafana 6.5.3
2

Kubernetes version v1.16.0 has Removed cadvisor metric labels pod_name and container_name to match instrumentation guidelines. Any Prometheus queries that match pod_name and container_name labels (e.g. cadvisor or kubelet probe metrics) must be updated to use pod and container instead.

You can check: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.16.md#metrics-changes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.