1、查看service/monitor-prometheus-server node-ip port
2、grafana添加数据源,Skip TLS Verification (Insecure) √ 勾选上;
3、import dashboard 模板
A:cluster模板

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    },
    {
      "name": "VAR_COSTCPU",
      "type": "constant",
      "label": "CPU",
      "value": "17.78",
      "description": ""
    },
    {
      "name": "VAR_COSTPCPU",
      "type": "constant",
      "label": "PE CPU",
      "value": "5.35",
      "description": ""
    },
    {
      "name": "VAR_COSTRAM",
      "type": "constant",
      "label": "RAM",
      "value": "2.38",
      "description": ""
    },
    {
      "name": "VAR_COSTPRAM",
      "type": "constant",
      "label": "PE RAM",
      "value": "0.72",
      "description": ""
    },
    {
      "name": "VAR_COSTSTORAGESTANDARD",
      "type": "constant",
      "label": "Storage",
      "value": "0.044",
      "description": ""
    },
    {
      "name": "VAR_COSTSTORAGESSD",
      "type": "constant",
      "label": "SSD",
      "value": "0.187",
      "description": ""
    },
    {
      "name": "VAR_COSTDISCOUNT",
      "type": "constant",
      "label": "Disc.",
      "value": "30",
      "description": ""
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.2.1"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "5.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": "5.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": "5.0.0"
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "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"
      }
    ]
  },
  "description": "A dashboard to help with cost and utilisation",
  "editable": true,
  "gnetId": 6873,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1530978789642,
  "links": [],
  "panels": [
    {
      "content": "This dashboard shows indicative monthly costing for the cluster, based on **current** requests for CPU, RAM and Storage.  \nUtilisation figures represent utilsation of current, active deployments vs their request limits, and **does not** include data from instances no longer running.",
      "gridPos": {
        "h": 2,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 86,
      "links": [],
      "mode": "markdown",
      "title": "",
      "transparent": true,
      "type": "text"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": true,
      "colors": [
        "rgba(245, 54, 54, 0.9)",
        "rgba(50, 172, 45, 0.97)",
        "#c15c17"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "This gauge shows the current CPU use vs CPU available",
      "editable": true,
      "error": false,
      "format": "percent",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": true,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 0,
        "y": 2
      },
      "height": "180px",
      "hideTimeOverride": true,
      "id": 82,
      "interval": null,
      "isNew": true,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "(\n  sum(\n    count(irate(container_cpu_usage_seconds_total{id=\"/\"}[1m])) by (instance)\n    * on (instance) \n    sum(irate(container_cpu_usage_seconds_total{id=\"/\"}[1m])) by (instance)\n  ) \n  / \n  (sum (kube_node_status_allocatable_cpu_cores))\n) * 100",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 1,
          "refId": "A",
          "step": 10
        }
      ],
      "thresholds": "30, 80",
      "timeFrom": "",
      "title": "CPU Utilisation",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": true,
      "colors": [
        "rgba(245, 54, 54, 0.9)",
        "rgba(50, 172, 45, 0.97)",
        "#c15c17"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "This panel shows current CPU reservation requests by applications, vs CPU available",
      "editable": true,
      "error": false,
      "format": "percent",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": true,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 3,
        "y": 2
      },
      "height": "180px",
      "id": 91,
      "interval": null,
      "isNew": true,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "(\n  sum(container_spec_cpu_shares{namespace!=\"\"})\n  / \n  (sum (kube_node_status_allocatable_cpu_cores) * 1000)\n) * 100",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 1,
          "refId": "A",
          "step": 10
        }
      ],
      "thresholds": "30, 80",
      "title": "CPU Requests",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "format": "currencyUSD",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 6,
        "y": 2
      },
      "id": 75,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "label_cloud_google_com_gke_preemptible",
      "targets": [
        {
          "expr": "sum(\n  (\n    (\n      sum(kube_node_status_capacity_cpu_cores) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible=\"true\"}\n    ) * $costpcpu\n  )\n  or\n  (\n    (\n      sum(kube_node_status_capacity_cpu_cores) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible!=\"true\"}\n    ) * ($costcpu - ($costcpu / 100 * $costDiscount))\n  )\n) ",
          "format": "time_series",
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": " {{ node }}",
          "refId": "A"
        }
      ],
      "thresholds": "",
      "timeShift": null,
      "title": "CPU Cost",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "format": "currencyUSD",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 10,
        "y": 2
      },
      "id": 78,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "label_cloud_google_com_gke_preemptible",
      "targets": [
        {
          "expr": "sum (\n  sum(kube_persistentvolumeclaim_info{storageclass=~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) / 1024 / 1024 /1024 * $costStorageSSD\n\n+\n\nsum (\n  sum(kube_persistentvolumeclaim_info{storageclass!~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) / 1024 / 1024 /1024 * $costStorageStandard\n\n+ \n\nsum(container_fs_limit_bytes{device=~\"^/dev/[sv]d[a-z][1-9]$\",id=\"/\"}) / 1024 / 1024 / 1024 * $costStorageStandard",
          "format": "time_series",
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": " {{ node }}",
          "refId": "A"
        }
      ],
      "thresholds": "",
      "timeShift": null,
      "title": "Storage Cost (Cluster and PVC)",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_PROMETHEUS}",
      "description": "This table shows the comparison of CPU and RAM requests by applications, vs the capacity of the node",
      "fontSize": "100%",
      "gridPos": {
        "h": 8,
        "w": 10,
        "x": 14,
        "y": 2
      },
      "hideTimeOverride": true,
      "id": 90,
      "links": [],
      "pageSize": 7,
      "repeatDirection": "v",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "RAM Requests",
          "colorMode": "value",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #A",
          "thresholds": [
            "30",
            " 80"
          ],
          "type": "number",
          "unit": "percent"
        },
        {
          "alias": "Node",
          "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,
          "mappingType": 1,
          "pattern": "node",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "CPU Requests",
          "colorMode": "value",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #B",
          "thresholds": [
            "30",
            " 80"
          ],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "expr": "( \n  sum(kube_pod_container_resource_requests_cpu_cores) by (node) \n  /\n  sum(kube_node_status_allocatable_cpu_cores) by (node)\n) * 100",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ node }}",
          "refId": "B"
        },
        {
          "expr": "( \n  sum(kube_pod_container_resource_requests_memory_bytes) by (node) \n  /\n  sum(kube_node_status_allocatable_memory_bytes) by (node)\n) * 100",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ node }}",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Cluster Node Utilisation by CPU and RAM requests",
      "transform": "table",
      "transparent": false,
      "type": "table"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": true,
      "colors": [
        "rgba(245, 54, 54, 0.9)",
        "rgba(50, 172, 45, 0.97)",
        "#c15c17"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "description": "This gauge shows current RAM use by RAM available",
      "editable": true,
      "error": false,
      "format": "percent",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": true,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 0,
        "y": 6
      },
      "height": "180px",
      "hideTimeOverride": true,
      "id": 80,
      "interval": null,
      "isNew": true,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "(\n  sum(\n    count(container_memory_working_set_bytes{id=\"/\"}) by (instance)\n    * on (instance) \n    sum(avg_over_time(container_memory_working_set_bytes{id=\"/\"}[1m])) by (instance)\n  )\n  /\n  sum(kube_node_status_allocatable_memory_bytes)\n) * 100",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 1,
          "refId": "A",
          "step": 10
        }
      ],
      "thresholds": "30,80",
      "timeFrom": "",
      "title": "RAM Utilisation",
      "transparent": false,
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": true,
      "colors": [
        "rgba(245, 54, 54, 0.9)",
        "rgba(50, 172, 45, 0.97)",
        "#c15c17"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "description": "This panel shows current RAM reservation requests by applications, vs RAM available",
      "editable": true,
      "error": false,
      "format": "percent",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": true,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 3,
        "y": 6
      },
      "height": "180px",
      "id": 92,
      "interval": null,
      "isNew": true,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "(\n  sum(kube_pod_container_resource_requests_memory_bytes{namespace!=\"\"})\n  /\n  sum(kube_node_status_allocatable_memory_bytes)\n) * 100",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 1,
          "refId": "A",
          "step": 10
        }
      ],
      "thresholds": "30,80",
      "title": "RAM Requests",
      "transparent": false,
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "format": "currencyUSD",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 6,
        "y": 6
      },
      "id": 77,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "label_cloud_google_com_gke_preemptible",
      "targets": [
        {
          "expr": "sum(\n  (\n    (\n      sum(kube_node_status_capacity_memory_bytes) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible=\"true\"}\n    ) /1024/1024/1024 * $costpram\n  )\n  or\n  (\n    (\n      sum(kube_node_status_capacity_memory_bytes) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible!=\"true\"}\n    ) /1024/1024/1024 * ($costram - ($costram / 100 * $costDiscount))\n)\n) ",
          "format": "time_series",
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": " {{ node }}",
          "refId": "A"
        }
      ],
      "thresholds": "",
      "timeShift": null,
      "title": "RAM Cost",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "format": "currencyUSD",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 10,
        "y": 6
      },
      "id": 93,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "label_cloud_google_com_gke_preemptible",
      "targets": [
        {
          "expr": "# CPU\nsum(\n  (\n    (\n      sum(kube_node_status_capacity_cpu_cores) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible=\"true\"}\n    ) * $costpcpu\n  )\n  or\n  (\n    (\n      sum(kube_node_status_capacity_cpu_cores) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible!=\"true\"}\n    ) * ($costcpu - ($costcpu / 100 * $costDiscount))\n  )\n) \n\n+ \n\n# Storage\nsum (\n  sum(kube_persistentvolumeclaim_info{storageclass=~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) / 1024 / 1024 /1024 * $costStorageSSD\n\n+\n\nsum (\n  sum(kube_persistentvolumeclaim_info{storageclass!~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) / 1024 / 1024 /1024 * $costStorageStandard\n\n+ \n\nsum(container_fs_limit_bytes{device=~\"^/dev/[sv]d[a-z][1-9]$\",id=\"/\"}) / 1024 / 1024 / 1024 * $costStorageStandard\n\n+ \n# RAM\nsum(\n  (\n    (\n      sum(kube_node_status_capacity_memory_bytes) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible=\"true\"}\n    ) /1024/1024/1024 * $costpram\n  )\n  or\n  (\n    (\n      sum(kube_node_status_capacity_memory_bytes) by (node)\n       * on (node) group_left (label_cloud_google_com_gke_preemptible)\n      kube_node_labels{label_cloud_google_com_gke_preemptible!=\"true\"}\n    ) /1024/1024/1024 * ($costram - ($costram / 100 * $costDiscount))\n)\n) ",
          "format": "time_series",
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": " {{ node }}",
          "refId": "A"
        }
      ],
      "thresholds": "",
      "timeShift": null,
      "title": "Total Cost",
      "type": "singlestat",
      "valueFontSize": "110%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 11,
        "w": 14,
        "x": 0,
        "y": 10
      },
      "hideTimeOverride": false,
      "id": 73,
      "links": [],
      "pageSize": 10,
      "repeat": null,
      "repeatDirection": "v",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 7,
        "desc": true
      },
      "styles": [
        {
          "alias": "Namespace",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#c15c17"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTooltip": "View namespace cost analysis",
          "linkUrl": "d/at-cost-analysis-namespace/cost-analysis-by-namespace?&var-namespace=$__cell",
          "pattern": "namespace",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "string",
          "unit": "currencyUSD"
        },
        {
          "alias": "RAM",
          "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": "Value #B",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "CPU",
          "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,
          "mappingType": 1,
          "pattern": "Value #A",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Storage",
          "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,
          "mappingType": 1,
          "pattern": "Value #C",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "Total",
          "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,
          "mappingType": 1,
          "pattern": "Value #D",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "CPU Utilisation",
          "colorMode": "value",
          "colors": [
            "#bf1b00",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #E",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        },
        {
          "alias": "RAM Utilisation",
          "colorMode": "value",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #F",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "expr": "(\n  sum(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible!=\"true\"}/1000*($costcpu - ($costcpu / 100 * $costDiscount))) by(namespace)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n  ) by(namespace) -1\n)\n\n+\n\n(\n  sum(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible=\"true\"}/1000*$costpcpu) by(namespace)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n  ) by(namespace) -1\n)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "A"
        },
        {
          "expr": "sum(\n   count(count(container_spec_cpu_shares{namespace!=\"\"}) by (pod_name, namespace)) by (pod_name, namespace)  \n   * on (pod_name, namespace) \n   sum(irate(container_cpu_usage_seconds_total{namespace!=\"\"}[1m])) by (pod_name, namespace)\n) by (namespace) * 1000\n/\nsum(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by (namespace) * 100\n",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "E"
        },
        {
          "expr": "(\n  sum(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible!=\"true\"}/1024/1024/1024*($costram- ($costram / 100 * $costDiscount))) by(namespace)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n  ) by(namespace) -1\n)\n\n+\n\n(\n  sum(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible=\"true\"}/1024/1024/1024*$costpram) by(namespace)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n  ) by(namespace) -1\n)",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "B"
        },
        {
          "expr": "sum(\n   count(count(container_memory_working_set_bytes{namespace!=\"\"}) by (pod_name, namespace)) by (pod_name, namespace)  \n   * on (pod_name, namespace) \n   sum(avg_over_time(container_memory_working_set_bytes{namespace!=\"\"}[1m])) by (pod_name, namespace)\n) by (namespace)\n/\nsum(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\"}) by (namespace) * 100\n",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "F"
        },
        {
          "expr": "sum (\n  sum(kube_persistentvolumeclaim_info{storageclass=~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) by (namespace) / 1024 / 1024 /1024 * $costStorageSSD\n\nor\n\nsum (\n  sum(kube_persistentvolumeclaim_info{storageclass!~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) by (namespace) / 1024 / 1024 /1024 * $costStorageStandard\n\nor\n\ncount(\n  count(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n) by(namespace) -1",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "C"
        },
        {
          "expr": "# Add the CPU\n(\n  (\n    sum(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible!=\"true\"}/1000*($costcpu - ($costcpu / 100 * $costDiscount))) by(namespace)\n    or\n    count(\n      count(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n    ) by(namespace) -1\n  )\n  \n  +\n  \n  (\n    sum(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible=\"true\"}/1000*$costpcpu) by(namespace)\n    or\n    count(\n      count(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n    ) by(namespace) -1\n  )\n)\n\n+ \n# Add the RAM\n(\n  (\n    sum(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible!=\"true\"}/1024/1024/1024*($costram - ($costram / 100 * $costDiscount))) by(namespace)\n    or\n    count(\n      count(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n    ) by(namespace) -1\n  )\n  \n  +\n  \n  (\n    sum(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\",cloud_google_com_gke_preemptible=\"true\"}/1024/1024/1024*$costpram) by(namespace)\n    or\n    count(\n      count(container_spec_memory_limit_bytes{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n    ) by(namespace) -1\n  )\n)\n\n+\n# Add the storage\n(\n\n  sum (\n    sum(kube_persistentvolumeclaim_info{storageclass=~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n    + on (persistentvolumeclaim, namespace) group_right(storageclass)\n    sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n  ) by (namespace) / 1024 / 1024 /1024 * $costStorageSSD\n  \n  or\n  \n  sum (\n    sum(kube_persistentvolumeclaim_info{storageclass!~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n    + on (persistentvolumeclaim, namespace) group_right(storageclass)\n    sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n  ) by (namespace) / 1024 / 1024 /1024 * $costStorageStandard\n  \n  or\n  \n  count(\n    count(container_spec_cpu_shares{namespace!=\"\",namespace!=\"kube-system\"}) by(namespace)\n  ) by(namespace) -1\n\n)",
          "format": "table",
          "instant": true,
          "intervalFactor": 1,
          "refId": "D"
        }
      ],
      "timeFrom": "",
      "timeShift": null,
      "title": "Namespace cost and utilisation analysis",
      "transform": "table",
      "transparent": false,
      "type": "table"
    },
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 11,
        "w": 10,
        "x": 14,
        "y": 10
      },
      "hideTimeOverride": true,
      "id": 94,
      "links": [],
      "pageSize": 10,
      "repeatDirection": "v",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 4,
        "desc": true
      },
      "styles": [
        {
          "alias": "Namespace",
          "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,
          "mappingType": 1,
          "pattern": "namespace",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "PVC Name",
          "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,
          "mappingType": 1,
          "pattern": "persistentvolumeclaim",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Storage Class",
          "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,
          "mappingType": 1,
          "pattern": "storageclass",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Cost",
          "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,
          "mappingType": 1,
          "pattern": "Value",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "expr": "sum (\n  sum(kube_persistentvolumeclaim_info{storageclass=~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) by (namespace,persistentvolumeclaim,storageclass) / 1024 / 1024 /1024 * $costStorageSSD\n\nor\n\nsum (\n  sum(kube_persistentvolumeclaim_info{storageclass!~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) by (persistentvolumeclaim, namespace)\n) by (namespace,persistentvolumeclaim,storageclass) / 1024 / 1024 /1024 * $costStorageStandard\n",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ persistentvolumeclaim }}",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Persistent Volume Claims",
      "transform": "table",
      "transparent": false,
      "type": "table"
    }
  ],
  "refresh": "10s",
  "schemaVersion": 16,
  "style": "dark",
  "tags": [
    "cost",
    "utilisation",
    "metrics"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "value": "${VAR_COSTCPU}",
          "text": "${VAR_COSTCPU}"
        },
        "hide": 0,
        "label": "CPU",
        "name": "costcpu",
        "options": [
          {
            "value": "${VAR_COSTCPU}",
            "text": "${VAR_COSTCPU}"
          }
        ],
        "query": "${VAR_COSTCPU}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTPCPU}",
          "text": "${VAR_COSTPCPU}"
        },
        "hide": 0,
        "label": "PE CPU",
        "name": "costpcpu",
        "options": [
          {
            "value": "${VAR_COSTPCPU}",
            "text": "${VAR_COSTPCPU}"
          }
        ],
        "query": "${VAR_COSTPCPU}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTRAM}",
          "text": "${VAR_COSTRAM}"
        },
        "hide": 0,
        "label": "RAM",
        "name": "costram",
        "options": [
          {
            "value": "${VAR_COSTRAM}",
            "text": "${VAR_COSTRAM}"
          }
        ],
        "query": "${VAR_COSTRAM}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTPRAM}",
          "text": "${VAR_COSTPRAM}"
        },
        "hide": 0,
        "label": "PE RAM",
        "name": "costpram",
        "options": [
          {
            "value": "${VAR_COSTPRAM}",
            "text": "${VAR_COSTPRAM}"
          }
        ],
        "query": "${VAR_COSTPRAM}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTSTORAGESTANDARD}",
          "text": "${VAR_COSTSTORAGESTANDARD}"
        },
        "hide": 0,
        "label": "Storage",
        "name": "costStorageStandard",
        "options": [
          {
            "value": "${VAR_COSTSTORAGESTANDARD}",
            "text": "${VAR_COSTSTORAGESTANDARD}"
          }
        ],
        "query": "${VAR_COSTSTORAGESTANDARD}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTSTORAGESSD}",
          "text": "${VAR_COSTSTORAGESSD}"
        },
        "hide": 0,
        "label": "SSD",
        "name": "costStorageSSD",
        "options": [
          {
            "value": "${VAR_COSTSTORAGESSD}",
            "text": "${VAR_COSTSTORAGESSD}"
          }
        ],
        "query": "${VAR_COSTSTORAGESSD}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTDISCOUNT}",
          "text": "${VAR_COSTDISCOUNT}"
        },
        "hide": 0,
        "label": "Disc.",
        "name": "costDiscount",
        "options": [
          {
            "value": "${VAR_COSTDISCOUNT}",
            "text": "${VAR_COSTDISCOUNT}"
          }
        ],
        "query": "${VAR_COSTDISCOUNT}",
        "type": "constant"
      }
    ]
  },
  "time": {
    "from": "now-15m",
    "to": "now"
  },
  "timepicker": {
    "hidden": false,
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "Analysis by Cluster",
  "uid": "at-cost-analysis",
  "version": 6
}

展示页:

 

B、namespace模板

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    },
    {
      "name": "VAR_COSTCPU",
      "type": "constant",
      "label": "CPU",
      "value": "17.78",
      "description": ""
    },
    {
      "name": "VAR_COSTPCPU",
      "type": "constant",
      "label": "PE CPU",
      "value": "5.35",
      "description": ""
    },
    {
      "name": "VAR_COSTRAM",
      "type": "constant",
      "label": "RAM",
      "value": "2.38",
      "description": ""
    },
    {
      "name": "VAR_COSTPRAM",
      "type": "constant",
      "label": "PE RAM",
      "value": "0.72",
      "description": ""
    },
    {
      "name": "VAR_COSTSTORAGESTANDARD",
      "type": "constant",
      "label": "Storage",
      "value": "0.044",
      "description": ""
    },
    {
      "name": "VAR_COSTSTORAGESSD",
      "type": "constant",
      "label": "SSD",
      "value": "0.187",
      "description": ""
    },
    {
      "name": "VAR_COSTDISCOUNT",
      "type": "constant",
      "label": "Disc.",
      "value": "30",
      "description": ""
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.2.1"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "5.0.0"
    },
    {
      "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"
      }
    ]
  },
  "description": "A dashboard to help with cost and utilisation",
  "editable": true,
  "gnetId": 6876,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1530978809451,
  "links": [],
  "panels": [
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 9,
        "w": 16,
        "x": 0,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 73,
      "links": [],
      "pageSize": 8,
      "repeat": null,
      "repeatDirection": "v",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 6,
        "desc": true
      },
      "styles": [
        {
          "alias": "Pod",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#c15c17"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": true,
          "linkTooltip": "Click to drill down into pod",
          "linkUrl": "d/at-cost-analysis-pod/cost-analysis-by-pod?&var-namespace=$namespace&var-pod=$__cell",
          "pattern": "pod_name",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "string",
          "unit": "currencyUSD"
        },
        {
          "alias": "RAM",
          "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": "Value #B",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "CPU",
          "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,
          "mappingType": 1,
          "pattern": "Value #A",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Storage",
          "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,
          "mappingType": 1,
          "pattern": "Value #C",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "Total",
          "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,
          "mappingType": 1,
          "pattern": "Value #D",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "CPU Utilisation",
          "colorMode": "value",
          "colors": [
            "#bf1b00",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #E",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        },
        {
          "alias": "RAM Utilisation",
          "colorMode": "value",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #F",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "expr": "(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",cloud_google_com_gke_preemptible!=\"true\"}/1000*($costcpu - ($costcpu / 100 * $costDiscount))) by(pod_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)\n\n+\n\n(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",cloud_google_com_gke_preemptible=\"true\"}/1000*$costpcpu) by(pod_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ pod_name }}",
          "refId": "A"
        },
        {
          "expr": "sum(\n   count(count(container_spec_cpu_shares{namespace=\"$namespace\"}) by (pod_name)) by (pod_name)  \n   * on (pod_name) \n   sum(irate(container_cpu_usage_seconds_total{namespace=\"$namespace\"}[1m])) by (pod_name)\n) by (pod_name) * 1000\n/\nsum(container_spec_cpu_shares{namespace=\"$namespace\"}) by (pod_name) * 100",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ pod_name }}",
          "refId": "E"
        },
        {
          "expr": "(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",cloud_google_com_gke_preemptible!=\"true\"}/1024/1024/1024*($costram- ($costram / 100 * $costDiscount))) by(pod_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)\n\n+\n\n(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",cloud_google_com_gke_preemptible=\"true\"}/1024/1024/1024*$costpram) by(pod_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "B"
        },
        {
          "expr": "sum(\n   count(count(container_memory_working_set_bytes{namespace=\"$namespace\"}) by (pod_name)) by (pod_name)  \n   * on (pod_name) \n   sum(avg_over_time(container_memory_working_set_bytes{namespace=\"$namespace\"}[1m])) by (pod_name)\n) by (pod_name)\n/\nsum(container_spec_memory_limit_bytes{namespace=\"$namespace\"}) by (pod_name) * 100",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "F"
        },
        {
          "expr": "(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",cloud_google_com_gke_preemptible!=\"true\"}/1000*($costcpu - ($costcpu / 100 * $costDiscount))) by(pod_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)\n\n+\n\n(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",cloud_google_com_gke_preemptible=\"true\"}/1000*$costpcpu) by(pod_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)\n\n# Now ram\n\n+ \n(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",cloud_google_com_gke_preemptible!=\"true\"}/1024/1024/1024*($costram- ($costram / 100 * $costDiscount))) by(pod_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)\n\n+\n\n(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",cloud_google_com_gke_preemptible=\"true\"}/1024/1024/1024*$costpram) by(pod_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\"}) by(pod_name)\n  ) by(pod_name) -1\n)\n\n",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "refId": "D"
        }
      ],
      "timeFrom": "1M",
      "timeShift": null,
      "title": "Pod cost and utilisation analysis",
      "transform": "table",
      "transparent": false,
      "type": "table"
    },
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 9,
        "w": 8,
        "x": 16,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 90,
      "links": [],
      "pageSize": 8,
      "repeatDirection": "v",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 4,
        "desc": true
      },
      "styles": [
        {
          "alias": "Namespace",
          "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,
          "mappingType": 1,
          "pattern": "namespace",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "PVC Name",
          "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,
          "mappingType": 1,
          "pattern": "persistentvolumeclaim",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Storage Class",
          "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,
          "mappingType": 1,
          "pattern": "storageclass",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Cost",
          "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,
          "mappingType": 1,
          "pattern": "Value",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "expr": "sum (\n  sum(kube_persistentvolumeclaim_info{storageclass=~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace=~\"$namespace\"}) by (persistentvolumeclaim, namespace)\n) by (namespace,persistentvolumeclaim,storageclass) / 1024 / 1024 /1024 * $costStorageSSD\n\nor\n\nsum (\n  sum(kube_persistentvolumeclaim_info{storageclass!~\".*ssd.*\"}) by (persistentvolumeclaim, namespace, storageclass)\n  + on (persistentvolumeclaim, namespace) group_right(storageclass)\n  sum(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace=~\"$namespace\"}) by (persistentvolumeclaim, namespace)\n) by (namespace,persistentvolumeclaim,storageclass) / 1024 / 1024 /1024 * $costStorageStandard\n",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ persistentvolumeclaim }}",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Persistent Volume Claims",
      "transform": "table",
      "transparent": false,
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 3,
      "description": "This panel shows historical utilisation as an average across all pods in this namespace.  It only accounts for currently deployed pods",
      "editable": true,
      "error": false,
      "fill": 0,
      "grid": {},
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "height": "",
      "id": 94,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": false,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": true,
      "targets": [
        {
          "expr": "sum (rate (container_cpu_usage_seconds_total{namespace=\"$namespace\"}[1m])) by (namespace) * 1000\n/\nsum(avg_over_time(container_spec_cpu_shares{namespace=\"$namespace\"}[1m])) by (namespace) * 100",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "10s",
          "intervalFactor": 1,
          "legendFormat": "cpu",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "Overall CPU Utilisation",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "percent",
          "label": "",
          "logBase": 1,
          "max": "110",
          "min": "0",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "This panel shows historical utilisation as an average across all pods in this namespace.  It only accounts for currently deployed pods",
      "editable": true,
      "error": false,
      "fill": 0,
      "grid": {},
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "id": 92,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": false,
        "sideWidth": 200,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": true,
      "targets": [
        {
          "expr": "sum (container_memory_working_set_bytes{namespace=\"$namespace\"}) by (namespace)\n/\nsum(container_spec_memory_limit_bytes{namespace=\"$namespace\"}) by (namespace) * 100",
          "format": "time_series",
          "interval": "10s",
          "intervalFactor": 1,
          "legendFormat": "ram",
          "metric": "container_memory_usage:sort_desc",
          "refId": "A",
          "step": 10
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "Overall RAM Utilisation",
      "tooltip": {
        "msResolution": false,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "percent",
          "label": null,
          "logBase": 1,
          "max": "110",
          "min": "0",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "Traffic in and out of this namespace, as a sum of the pods within it",
      "editable": true,
      "error": false,
      "fill": 1,
      "grid": {},
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 0,
        "y": 15
      },
      "height": "",
      "id": 96,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": true,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum (rate (container_network_receive_bytes_total{namespace=\"$namespace\"}[1m])) by (namespace)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "<- in",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        },
        {
          "expr": "- sum (rate (container_network_transmit_bytes_total{namespace=\"$namespace\"}[1m])) by (namespace)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "-> out",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "Network IO",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "Disk reads and writes for the namespace, as a sum of the pods within it",
      "editable": true,
      "error": false,
      "fill": 1,
      "grid": {},
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 12,
        "y": 15
      },
      "height": "",
      "id": 98,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": true,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum (rate (container_fs_writes_bytes_total{namespace=\"$namespace\"}[1m])) by (namespace)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "<- write",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        },
        {
          "expr": "- sum (rate (container_fs_reads_bytes_total{namespace=\"$namespace\"}[1m])) by (namespace)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "-> read",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "Disk IO",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": "10s",
  "schemaVersion": 16,
  "style": "dark",
  "tags": [
    "cost",
    "utilisation",
    "metrics"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "value": "${VAR_COSTCPU}",
          "text": "${VAR_COSTCPU}"
        },
        "hide": 0,
        "label": "CPU",
        "name": "costcpu",
        "options": [
          {
            "value": "${VAR_COSTCPU}",
            "text": "${VAR_COSTCPU}"
          }
        ],
        "query": "${VAR_COSTCPU}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTPCPU}",
          "text": "${VAR_COSTPCPU}"
        },
        "hide": 0,
        "label": "PE CPU",
        "name": "costpcpu",
        "options": [
          {
            "value": "${VAR_COSTPCPU}",
            "text": "${VAR_COSTPCPU}"
          }
        ],
        "query": "${VAR_COSTPCPU}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTRAM}",
          "text": "${VAR_COSTRAM}"
        },
        "hide": 0,
        "label": "RAM",
        "name": "costram",
        "options": [
          {
            "value": "${VAR_COSTRAM}",
            "text": "${VAR_COSTRAM}"
          }
        ],
        "query": "${VAR_COSTRAM}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTPRAM}",
          "text": "${VAR_COSTPRAM}"
        },
        "hide": 0,
        "label": "PE RAM",
        "name": "costpram",
        "options": [
          {
            "value": "${VAR_COSTPRAM}",
            "text": "${VAR_COSTPRAM}"
          }
        ],
        "query": "${VAR_COSTPRAM}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTSTORAGESTANDARD}",
          "text": "${VAR_COSTSTORAGESTANDARD}"
        },
        "hide": 0,
        "label": "Storage",
        "name": "costStorageStandard",
        "options": [
          {
            "value": "${VAR_COSTSTORAGESTANDARD}",
            "text": "${VAR_COSTSTORAGESTANDARD}"
          }
        ],
        "query": "${VAR_COSTSTORAGESTANDARD}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTSTORAGESSD}",
          "text": "${VAR_COSTSTORAGESSD}"
        },
        "hide": 0,
        "label": "SSD",
        "name": "costStorageSSD",
        "options": [
          {
            "value": "${VAR_COSTSTORAGESSD}",
            "text": "${VAR_COSTSTORAGESSD}"
          }
        ],
        "query": "${VAR_COSTSTORAGESSD}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTDISCOUNT}",
          "text": "${VAR_COSTDISCOUNT}"
        },
        "hide": 0,
        "label": "Disc.",
        "name": "costDiscount",
        "options": [
          {
            "value": "${VAR_COSTDISCOUNT}",
            "text": "${VAR_COSTDISCOUNT}"
          }
        ],
        "query": "${VAR_COSTDISCOUNT}",
        "type": "constant"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "hide": 0,
        "includeAll": false,
        "label": "NS",
        "multi": false,
        "name": "namespace",
        "options": [],
        "query": "query_result(sum(container_memory_working_set_bytes{namespace!=\"\"}) by (namespace))",
        "refresh": 1,
        "regex": "/namespace=\\\"(.*?)(\\\")/",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-15m",
    "to": "now"
  },
  "timepicker": {
    "hidden": false,
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "Analysis by Namespace",
  "uid": "at-cost-analysis-namespace",
  "version": 8
}

展示页:

 

C、pod 模板

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    },
    {
      "name": "VAR_COSTCPU",
      "type": "constant",
      "label": "CPU",
      "value": "17.78",
      "description": ""
    },
    {
      "name": "VAR_COSTPCPU",
      "type": "constant",
      "label": "PE CPU",
      "value": "5.35",
      "description": ""
    },
    {
      "name": "VAR_COSTRAM",
      "type": "constant",
      "label": "RAM",
      "value": "2.38",
      "description": ""
    },
    {
      "name": "VAR_COSTPRAM",
      "type": "constant",
      "label": "PE RAM",
      "value": "0.72",
      "description": ""
    },
    {
      "name": "VAR_COSTSTORAGESTANDARD",
      "type": "constant",
      "label": "Storage",
      "value": "0.044",
      "description": ""
    },
    {
      "name": "VAR_COSTSTORAGESSD",
      "type": "constant",
      "label": "SSD",
      "value": "0.187",
      "description": ""
    },
    {
      "name": "VAR_COSTDISCOUNT",
      "type": "constant",
      "label": "Disc.",
      "value": "30",
      "description": ""
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.2.1"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "5.0.0"
    },
    {
      "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"
      }
    ]
  },
  "description": "Part 3 of 3 dashboards to help you visualise your kubernetes costs.",
  "editable": true,
  "gnetId": 6879,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1530978819826,
  "links": [],
  "panels": [
    {
      "columns": [
        {
          "text": "Avg",
          "value": "avg"
        }
      ],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 73,
      "links": [],
      "pageSize": 3,
      "repeat": null,
      "repeatDirection": "v",
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 6,
        "desc": true
      },
      "styles": [
        {
          "alias": "Container",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#c15c17"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "pattern": "container_name",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "string",
          "unit": "currencyUSD"
        },
        {
          "alias": "RAM",
          "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": "Value #B",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "CPU",
          "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,
          "mappingType": 1,
          "pattern": "Value #A",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "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,
          "mappingType": 1,
          "pattern": "Time",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Storage",
          "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,
          "mappingType": 1,
          "pattern": "Value #C",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "Total",
          "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,
          "mappingType": 1,
          "pattern": "Value #D",
          "thresholds": [],
          "type": "number",
          "unit": "currencyUSD"
        },
        {
          "alias": "CPU Utilisation",
          "colorMode": "value",
          "colors": [
            "#bf1b00",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #E",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        },
        {
          "alias": "RAM Utilisation",
          "colorMode": "value",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(50, 172, 45, 0.97)",
            "#ef843c"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Value #F",
          "thresholds": [
            "30",
            "80"
          ],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "expr": "(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible!=\"true\"}/1000*($costcpu - ($costcpu / 100 * $costDiscount))) by(container_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\",container_name!=\"POD\",pod_name=\"$pod\"}) by(container_name)\n  ) by(container_name) -1\n)\n\n+\n\n(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible=\"true\"}/1000*$costpcpu) by(container_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by(container_name)\n  ) by(container_name) -1\n)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ pod_name }}",
          "refId": "A"
        },
        {
          "expr": "sum(\n   count(count(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by (container_name)) by (container_name)  \n   * on (container_name) \n   sum(irate(container_cpu_usage_seconds_total{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}[1m])) by (container_name)\n) by (container_name) * 1000\n/\nsum(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by (container_name) * 100",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ pod_name }}",
          "refId": "E"
        },
        {
          "expr": "(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible!=\"true\"}/1024/1024/1024*($costram- ($costram / 100 * $costDiscount))) by(container_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by(container_name)\n  ) by(container_name) -1\n)\n\n+\n\n(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible=\"true\"}/1024/1024/1024*$costpram) by(container_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by(container_name)\n  ) by(container_name) -1\n)",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "B"
        },
        {
          "expr": "sum(\n   count(count(container_memory_working_set_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by (container_name)) by (container_name)  \n   * on (container_name) \n   sum(avg_over_time(container_memory_working_set_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}[1m])) by (container_name)\n) by (container_name)\n/\nsum(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by (container_name) * 100",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "legendFormat": "{{ namespace }}",
          "refId": "F"
        },
        {
          "expr": "(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible!=\"true\"}/1000*($costcpu - ($costcpu / 100 * $costDiscount))) by(container_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\",container_name!=\"POD\",pod_name=\"$pod\"}) by(container_name)\n  ) by(container_name) -1\n)\n\n+\n\n(\n  sum(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible=\"true\"}/1000*$costpcpu) by(container_name)\n  or\n  count(\n    count(container_spec_cpu_shares{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by(container_name)\n  ) by(container_name) -1\n)\n\n+\n\n(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible!=\"true\"}/1024/1024/1024*($costram- ($costram / 100 * $costDiscount))) by(container_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by(container_name)\n  ) by(container_name) -1\n)\n\n+\n\n(\n  sum(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\",cloud_google_com_gke_preemptible=\"true\"}/1024/1024/1024*$costpram) by(container_name)\n  or\n  count(\n    count(container_spec_memory_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\",container_name!=\"POD\"}) by(container_name)\n  ) by(container_name) -1\n)",
          "format": "table",
          "hide": false,
          "instant": true,
          "intervalFactor": 1,
          "refId": "D"
        }
      ],
      "timeFrom": "1M",
      "timeShift": null,
      "title": "Container cost and utilisation analysis",
      "transform": "table",
      "transparent": false,
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 3,
      "description": "This graph attempts to show you CPU use of your application vs its requests",
      "editable": true,
      "error": false,
      "fill": 0,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 0,
        "y": 6
      },
      "height": "",
      "id": 94,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": true,
      "targets": [
        {
          "expr": "sum (rate (container_cpu_usage_seconds_total{namespace=~\"$namespace\", pod_name=\"$pod\", container_name!=\"POD\"}[1m])) by (container_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ container_name }}",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        },
        {
          "expr": "sum(container_spec_cpu_shares{namespace=~\"$namespace\", pod_name=\"$pod\", container_name!=\"POD\"}) by (container_name) / 1000",
          "format": "time_series",
          "instant": false,
          "intervalFactor": 1,
          "legendFormat": "{{ container_name }} (requested)",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "CPU Core Usage vs Requested",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "none",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 3,
      "description": "This graph attempts to show you RAM use of your application vs its requests",
      "editable": true,
      "error": false,
      "fill": 0,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 12,
        "y": 6
      },
      "height": "",
      "id": 96,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": true,
      "targets": [
        {
          "expr": "sum (avg_over_time (container_memory_working_set_bytes{namespace=\"$namespace\", pod_name=\"$pod\", container_name!=\"POD\"}[1m])) by (container_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ container_name }}",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        },
        {
          "expr": "sum(container_spec_memory_limit_bytes{namespace=~\"$namespace\", pod_name=\"$pod\", container_name!=\"POD\"}) by (container_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "intervalFactor": 1,
          "legendFormat": "{{ container_name }} (requested)",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "RAM Usage vs Requested",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "bytes",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "Traffic in and out of this pod, as a sum of its containers",
      "editable": true,
      "error": false,
      "fill": 1,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 0,
        "y": 13
      },
      "height": "",
      "id": 95,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": true,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum (rate (container_network_receive_bytes_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (pod_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "<- in",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        },
        {
          "expr": "- sum (rate (container_network_transmit_bytes_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (pod_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "-> out",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "Network IO",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 2,
      "description": "Disk read writes",
      "editable": true,
      "error": false,
      "fill": 1,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 12,
        "y": 13
      },
      "height": "",
      "id": 97,
      "isNew": true,
      "legend": {
        "alignAsTable": false,
        "avg": true,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": null,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum (rate (container_fs_writes_bytes_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (pod_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "<- write",
          "metric": "container_cpu",
          "refId": "A",
          "step": 10
        },
        {
          "expr": "- sum (rate (container_fs_reads_bytes_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (pod_name)",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "-> read",
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": "",
      "timeShift": null,
      "title": "Disk IO",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 2,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": "10s",
  "schemaVersion": 16,
  "style": "dark",
  "tags": [
    "cost",
    "utilisation",
    "metrics"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "value": "${VAR_COSTCPU}",
          "text": "${VAR_COSTCPU}"
        },
        "hide": 0,
        "label": "CPU",
        "name": "costcpu",
        "options": [
          {
            "value": "${VAR_COSTCPU}",
            "text": "${VAR_COSTCPU}"
          }
        ],
        "query": "${VAR_COSTCPU}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTPCPU}",
          "text": "${VAR_COSTPCPU}"
        },
        "hide": 0,
        "label": "PE CPU",
        "name": "costpcpu",
        "options": [
          {
            "value": "${VAR_COSTPCPU}",
            "text": "${VAR_COSTPCPU}"
          }
        ],
        "query": "${VAR_COSTPCPU}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTRAM}",
          "text": "${VAR_COSTRAM}"
        },
        "hide": 0,
        "label": "RAM",
        "name": "costram",
        "options": [
          {
            "value": "${VAR_COSTRAM}",
            "text": "${VAR_COSTRAM}"
          }
        ],
        "query": "${VAR_COSTRAM}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTPRAM}",
          "text": "${VAR_COSTPRAM}"
        },
        "hide": 0,
        "label": "PE RAM",
        "name": "costpram",
        "options": [
          {
            "value": "${VAR_COSTPRAM}",
            "text": "${VAR_COSTPRAM}"
          }
        ],
        "query": "${VAR_COSTPRAM}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTSTORAGESTANDARD}",
          "text": "${VAR_COSTSTORAGESTANDARD}"
        },
        "hide": 0,
        "label": "Storage",
        "name": "costStorageStandard",
        "options": [
          {
            "value": "${VAR_COSTSTORAGESTANDARD}",
            "text": "${VAR_COSTSTORAGESTANDARD}"
          }
        ],
        "query": "${VAR_COSTSTORAGESTANDARD}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTSTORAGESSD}",
          "text": "${VAR_COSTSTORAGESSD}"
        },
        "hide": 0,
        "label": "SSD",
        "name": "costStorageSSD",
        "options": [
          {
            "value": "${VAR_COSTSTORAGESSD}",
            "text": "${VAR_COSTSTORAGESSD}"
          }
        ],
        "query": "${VAR_COSTSTORAGESSD}",
        "type": "constant"
      },
      {
        "current": {
          "value": "${VAR_COSTDISCOUNT}",
          "text": "${VAR_COSTDISCOUNT}"
        },
        "hide": 0,
        "label": "Disc.",
        "name": "costDiscount",
        "options": [
          {
            "value": "${VAR_COSTDISCOUNT}",
            "text": "${VAR_COSTDISCOUNT}"
          }
        ],
        "query": "${VAR_COSTDISCOUNT}",
        "type": "constant"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "hide": 0,
        "includeAll": false,
        "label": "NS",
        "multi": false,
        "name": "namespace",
        "options": [],
        "query": "query_result(sum(container_memory_working_set_bytes{namespace!=\"\"}) by (namespace))",
        "refresh": 1,
        "regex": "/namespace=\\\"(.*?)(\\\")/",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "hide": 0,
        "includeAll": false,
        "label": "Pod",
        "multi": false,
        "name": "pod",
        "options": [],
        "query": "query_result(sum(container_memory_working_set_bytes{namespace=\"$namespace\"}) by (pod_name))",
        "refresh": 1,
        "regex": "/pod_name=\\\"(.*?)(\\\")/",
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-15m",
    "to": "now"
  },
  "timepicker": {
    "hidden": false,
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "Analysis by Pod",
  "uid": "at-cost-analysis-pod",
  "version": 4
}

展示页:

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐