Grafana Dashboards list pods within namespace not working

8/31/2021

I have grafana Dashboards, Pods drop down coming None within namespace, however we have pods running in namespace and pulling data prometheus.

Screenshot:

enter image description here

Query:

          "datasource": "Prometheus",
          "definition": "",
          "description": null,
          "error": null,
          "hide": 0,
          "includeAll": false,
          "label": "Pod",
          "multi": false,
          "name": "pod",
          "options": [],
          "query": {
            "query": "query_result(sum(container_memory_working_set_bytes{namespace=\"$namespace\"}) by (pod_name))",
            "refId": "Prometheus-pod-Variable-Query"
          },
          "refresh": 1,
          "regex": "/pod_name=\\\"(.*?)(\\\")/",
          "skipUrlSync": false,
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false

I am imported json code: https://grafana.com/grafana/dashboards/6879

-- Vidya
grafana
grafana-templating
kubernetes
prometheus
prometheus-alertmanager

2 Answers

8/31/2021

This might not be a full answer, but I cannot yet comment.

The linked dashboard imports and works for me fine. So I suspect one of these:

  • Prometheus scraping is not running (correctly). You could enter directly into the Prometheus app and check whether if the container_memory_working_set_bytes metric has any value at all, anywhere.
  • The kube_system system namespace might be restricted with respect to scraping and such. If another namespace works and only this one doesn't, then this is the case.
-- alparius
Source: StackOverflow

9/1/2021

Edit your dashboard's JSON:
Rename "pod_name" to "pod" in the 2 places (and save)

Looks like this grafana dashboard was created with older kubernetes version,
and metrics internals since changed.

Probably will also need similar edits for "container_name" changing to "container" in these older dashboards

-- siwasaki
Source: StackOverflow