---
apiVersion: v1
kind: ConfigMap
metadata:
  name: dashboard-provisioning
  namespace: monitoring
  labels:
    grafana_dashboard: ""
data:
  container-provisioning-dashboard.json: |
    {
      "__inputs": [],
      "__requires": [
        {
          "type": "grafana",
          "id": "grafana",
          "name": "Grafana",
          "version": "5.4.2"
        },
        {
          "type": "datasource",
          "id": "prometheus",
          "name": "Prometheus",
          "version": "5.0.0"
        },
        {
          "type": "panel",
          "id": "table",
          "name": "Table",
          "version": "5.0.0"
        }
      ],
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": "-- Grafana --",
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations & Alerts",
            "type": "dashboard"
          }
        ]
      },
      "editable": true,
      "gnetId": null,
      "graphTooltip": 0,
      "id": null,
      "iteration": 1548091959027,
      "links": [],
      "panels": [
        {
          "columns": [],
          "datasource": "Prometheus",
          "description": "Over provisioned containers in regards to CPU",
          "fontSize": "100%",
          "gridPos": {
            "h": 12,
            "w": 12,
            "x": 0,
            "y": 0
          },
          "id": 2,
          "links": [],
          "pageSize": 10,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 4,
            "desc": true
          },
          "styles": [
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Time",
              "thresholds": [],
              "type": "hidden",
              "unit": "short"
            },
            {
              "alias": "",
              "colorMode": "cell",
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(245, 54, 54, 0.9)"
              ],
              "decimals": 2,
              "pattern": "Value",
              "thresholds": [
                "100",
                "200"
              ],
              "type": "number",
              "unit": "none"
            },
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "link": false,
              "mappingType": 1,
              "pattern": "container",
              "preserveFormat": false,
              "sanitize": false,
              "thresholds": [],
              "type": "string",
              "unit": "short"
            }
          ],
          "targets": [
            {
              "expr": "topk(10,\n  avg(\n    sum(kube_pod_container_resource_requests_cpu_cores) by (namespace, pod, container) -\n    sum(\n      label_replace(\n        label_replace(\n          rate(container_cpu_usage_seconds_total{namespace =~ \"^${namespace}$\"}[5m]),\n          \"pod\", \"$1\", \"pod_name\", \"(.*)\"\n        ),\n        \"container\", \"$1\", \"container_name\", \"(.*)\"\n      )\n    ) by (namespace, pod, container)\n  )\n  by (namespace, pod, container)\n) * 1000",
              "format": "table",
              "interval": "5m",
              "intervalFactor": 2,
              "refId": "A",
              "step": 600
            }
          ],
          "timeFrom": "5m",
          "title": "CPU Over",
          "transform": "table",
          "transparent": false,
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "Prometheus",
          "description": "Under provisioned containers in regards to CPU",
          "fontSize": "100%",
          "gridPos": {
            "h": 12,
            "w": 12,
            "x": 12,
            "y": 0
          },
          "id": 3,
          "links": [],
          "pageSize": 10,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 4,
            "desc": true
          },
          "styles": [
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Time",
              "thresholds": [],
              "type": "hidden",
              "unit": "short"
            },
            {
              "alias": "",
              "colorMode": "cell",
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(245, 54, 54, 0.9)"
              ],
              "decimals": 2,
              "pattern": "Value",
              "thresholds": [
                "100",
                "200"
              ],
              "type": "number",
              "unit": "none"
            }
          ],
          "targets": [
            {
              "expr": "topk(10,\n  avg(\n    sum(\n      label_replace(\n        label_replace(\n          rate(container_cpu_usage_seconds_total{namespace =~ \"^${namespace}$\"}[5m]),\n          \"pod\", \"$1\", \"pod_name\", \"(.*)\"\n        ),\n        \"container\", \"$1\", \"container_name\", \"(.*)\"\n      )\n    ) by (namespace, pod, container) -\n    sum(kube_pod_container_resource_requests_cpu_cores) by (namespace, pod, container)\n  )\n  by (namespace, pod, container)\n) * 1000",
              "format": "table",
              "interval": "5m",
              "intervalFactor": 2,
              "refId": "A",
              "step": 600
            }
          ],
          "timeFrom": "5m",
          "title": "CPU Under",
          "transform": "table",
          "transparent": false,
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "Prometheus",
          "description": "Over provisioned containers in regards to Memory",
          "fontSize": "100%",
          "gridPos": {
            "h": 12,
            "w": 12,
            "x": 0,
            "y": 12
          },
          "id": 4,
          "links": [],
          "pageSize": 10,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 4,
            "desc": true
          },
          "styles": [
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Time",
              "thresholds": [],
              "type": "hidden",
              "unit": "short"
            },
            {
              "alias": "",
              "colorMode": "cell",
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(245, 54, 54, 0.9)"
              ],
              "decimals": 2,
              "pattern": "Value",
              "thresholds": [
                "1000000",
                "500000000"
              ],
              "type": "number",
              "unit": "decbytes"
            }
          ],
          "targets": [
            {
              "expr": "topk(10,\n  avg(\n    sum(kube_pod_container_resource_requests_memory_bytes{namespace =~ \"^${namespace}$\"}) by (namespace, pod, container) -\n    sum(\n      label_replace(\n        label_replace(\n          container_memory_usage_bytes,\n          \"pod\", \"$1\", \"pod_name\", \"(.*)\"\n        ),\n        \"container\", \"$1\", \"container_name\", \"(.*)\"\n      )\n    ) by (namespace, pod, container)\n  )\n  by (namespace, pod, container)\n)",
              "format": "table",
              "interval": "5m",
              "intervalFactor": 2,
              "refId": "A",
              "step": 600
            }
          ],
          "timeFrom": "5m",
          "title": "Memory Over",
          "transform": "table",
          "transparent": false,
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "Prometheus",
          "description": "Under provisioned containers in regards to Memory",
          "fontSize": "100%",
          "gridPos": {
            "h": 12,
            "w": 12,
            "x": 12,
            "y": 12
          },
          "id": 5,
          "links": [],
          "pageSize": 10,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": null,
            "desc": false
          },
          "styles": [
            {
              "alias": "",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "pattern": "Time",
              "thresholds": [],
              "type": "hidden",
              "unit": "short"
            },
            {
              "alias": "",
              "colorMode": "cell",
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(245, 54, 54, 0.9)"
              ],
              "decimals": 2,
              "pattern": "Value",
              "thresholds": [
                "10000000",
                "500000000"
              ],
              "type": "number",
              "unit": "decbytes"
            }
          ],
          "targets": [
            {
              "expr": "topk(10,\n  avg(\n    sum(\n      label_replace(\n        label_replace(\n          container_memory_usage_bytes{namespace =~ \"^${namespace}$\"},\n          \"pod\", \"$1\", \"pod_name\", \"(.*)\"\n        ),\n        \"container\", \"$1\", \"container_name\", \"(.*)\"\n      )\n    ) by (namespace, pod, container) -\n    sum(kube_pod_container_resource_requests_memory_bytes) by (namespace, pod, container)\n  )\n  by (namespace, pod, container)\n)",
              "format": "table",
              "interval": "5m",
              "intervalFactor": 2,
              "refId": "A",
              "step": 600
            }
          ],
          "timeFrom": "5m",
          "title": "Memory Under",
          "transform": "table",
          "transparent": false,
          "type": "table"
        }
      ],
      "schemaVersion": 16,
      "style": "dark",
      "tags": [
        "system",
        "kubernetes",
        "resources"
      ],
      "templating": {
        "list": [
          {
            "allValue": ".*",
            "current": {},
            "datasource": "Prometheus",
            "definition": "label_values(namespace)",
            "hide": 0,
            "includeAll": true,
            "label": "Namespace",
            "multi": true,
            "name": "namespace",
            "options": [],
            "query": "label_values(namespace)",
            "refresh": 1,
            "regex": "",
            "skipUrlSync": false,
            "sort": 0,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": false
          }
        ]
      },
      "time": {
        "from": "now-1h",
        "to": "now"
      },
      "timepicker": {
        "refresh_intervals": [
          "5s",
          "10s",
          "30s",
          "1m",
          "5m",
          "15m",
          "30m",
          "1h",
          "2h",
          "1d"
        ],
        "time_options": [
          "5m",
          "15m",
          "1h",
          "6h",
          "12h",
          "24h",
          "2d",
          "7d",
          "30d"
        ]
      },
      "timezone": "",
      "title": "Resource Provisioning",
      "uid": "fc680df439508874dae3f3f7fc866ab16648882f",
      "version": 1
    }
