Grafana dashboard: Monitoring VMs on OpenStack (or KVM) using Graphite + Collectd
Description: Collect metric of instances via Libvirt on all Compute node

Install Collectd on all Compute node (or KVM node) or any node that installed Libvirt to collect the metrics (ram, cpu, iops,..) of VMs, then push to a Graphite server.

Workflow: Collectd -> Graphite -> Grafana

{
  "__inputs": [
    {
      "name": "DS_GRAPHITE",
      "label": "Graphite",
      "description": "",
      "type": "datasource",
      "pluginId": "graphite",
      "pluginName": "Graphite"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.4.4"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "graphite",
      "name": "Graphite",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Collect metric of instances via Libvirt on all Compute node",
  "editable": true,
  "gnetId": 12294,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1589443060126,
  "links": [],
  "panels": [
    {
      "content": "<br>\n<a href=\"https://www.meditech.vn/\" ><h1 style=\"text-align: center;\"><img width=\"auto\" height=\"auto\" src=https://retail.iview.vn/wp-content/themes/retail-iview/assets/images/home/logo.png></h1></a>\n<br>\n<h1 style=\"text-align: center\"><span style=\"color: #ffffff;\"><strong>Trangnth</strong></span></h1>\n\n\n\n\n",
      "datasource": null,
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 0,
        "y": 0
      },
      "id": 15,
      "mode": "html",
      "options": {},
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "text"
    },
    {
      "datasource": "${DS_GRAPHITE}",
      "gridPos": {
        "h": 7,
        "w": 21,
        "x": 3,
        "y": 0
      },
      "id": 16,
      "links": [],
      "options": {
        "displayMode": "lcd",
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [],
            "max": 100,
            "min": 0,
            "thresholds": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 40
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "override": {},
          "values": false
        },
        "orientation": "horizontal"
      },
      "pluginVersion": "6.4.4",
      "targets": [
        {
          "hide": true,
          "refCount": 2,
          "refId": "A",
          "target": "collectd.$compute.$uuid.$virt.percent-virt_cpu_total"
        },
        {
          "hide": true,
          "refCount": 1,
          "refId": "G",
          "target": "divideSeries(multiplySeries(#A, #I), #K)",
          "targetFull": "divideSeries(multiplySeries(collectd.$compute.$uuid.$virt.percent-virt_cpu_total, countSeries(collectd.$compute.$uuid.$virt.*affinity-vcpu_0*)), countSeries(collectd.$compute.$uuid.$virt.virt_vcpu-*))"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "J",
          "target": "countSeries(collectd.$compute.$uuid.$virt.cpu_affinity-vcpu_[0-9]*-cpu_0)"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "K",
          "target": "countSeries(collectd.$compute.$uuid.$virt.virt_vcpu-*)"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "I",
          "target": "countSeries(collectd.$compute.$uuid.$virt.*affinity-vcpu_0*)"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "B",
          "target": "collectd.$compute.$uuid.$virt.virt_cpu_total"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "C",
          "target": "scale(countSeries(collectd.$compute.$uuid.$virt.virt_vcpu-*), 1000000000)"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "H",
          "target": "scale(offset(scale(collectd.$compute.$uuid.$virt.virt_vcpu-*, 0), 1), 1000000000)"
        },
        {
          "hide": false,
          "refCount": 1,
          "refId": "D",
          "target": "aliasSub(scale(divideSeries(#B, #C), 100), '^scale\\(divideSeries\\((.*)\\.(.*)\\.(.*)\\.virt_cpu_total(.*)*', '\\3')",
          "targetFull": "aliasSub(scale(divideSeries(collectd.$compute.$uuid.$virt.virt_cpu_total, scale(countSeries(collectd.$compute.$uuid.$virt.virt_vcpu-*), 1000000000)), 100), '^scale\\(divideSeries\\((.*)\\.(.*)\\.(.*)\\.virt_cpu_total(.*)*', '\\3')"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "F",
          "target": "smartSummarize(collectd.$compute.$uuid.$virt.percent-virt_cpu_total, '1h', 'sum')"
        },
        {
          "hide": true,
          "refCount": 2,
          "refId": "E",
          "target": "summarize(collectd.$compute.$uuid.$virt.percent-virt_cpu_total, '1h', 'sum', true)"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "CPU used",
      "type": "bargauge"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 0,
        "y": 7
      },
      "id": 11,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pluginVersion": "6.4.4",
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "hide": true,
          "refCount": 0,
          "refId": "A",
          "target": "collectd.$compute.$uuid.$virt.memory-unused"
        },
        {
          "hide": true,
          "refCount": 1,
          "refId": "B",
          "target": "collectd.$compute.$uuid.$virt.memory-total"
        },
        {
          "hide": true,
          "refCount": 0,
          "refId": "C",
          "target": "scale(divideSeries(#A, #B), 100)",
          "targetFull": "scale(divideSeries(collectd.$compute.$uuid.$virt.memory-unused, collectd.$compute.$uuid.$virt.memory-total), 100)"
        },
        {
          "hide": false,
          "refCount": 1,
          "refId": "E",
          "target": "aliasByNode(scale(#A, 1e-9), 3)",
          "targetFull": "aliasByNode(scale(collectd.$compute.$uuid.$virt.memory-unused, 1e-9), 3)"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Ram Free",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {
        "leftLogBase": 1,
        "leftMax": null,
        "leftMin": null,
        "rightLogBase": 1,
        "rightMax": null,
        "rightMin": null
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 8,
        "y": 7
      },
      "id": 5,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": true,
        "hideZero": true,
        "max": true,
        "min": false,
        "show": true,
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "/write/",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "hide": false,
          "refCount": 0,
          "refId": "A",
          "target": "alias(collectd.$compute.$uuid.$virt.disk_octets-vda.read, 'read')"
        },
        {
          "hide": false,
          "refCount": 0,
          "refId": "B",
          "target": "alias(collectd.$compute.$uuid.$virt.$diskops.write, 'write')"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "DISK IOPS $uuid",
      "tooltip": {
        "msResolution": false,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "x-axis": true,
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "y-axis": true,
      "y_formats": [
        "none",
        "Bps"
      ],
      "yaxes": [
        {
          "format": "ops",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAPHITE}",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {
        "leftLogBase": 1,
        "leftMax": null,
        "leftMin": null,
        "rightLogBase": 1,
        "rightMax": null,
        "rightMin": null
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 16,
        "y": 7
      },
      "id": 3,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": true,
        "hideZero": true,
        "max": true,
        "min": true,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "/.+In/",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "hide": false,
          "refCount": 0,
          "refId": "A",
          "target": "alias(collectd.$compute.$uuid.$virt.$interface.tx, 'Data Out')"
        },
        {
          "refCount": 0,
          "refId": "B",
          "target": "alias(collectd.$compute.$uuid.$virt.$interface.rx, 'Data In')"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Network $uuid",
      "tooltip": {
        "msResolution": false,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "x-axis": true,
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "y-axis": true,
      "y_formats": [
        "Bps",
        "Bps"
      ],
      "yaxes": [
        {
          "format": "Bps",
          "label": null,
          "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_GRAPHITE}",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {
        "leftLogBase": 1,
        "leftMax": null,
        "leftMin": null,
        "rightLogBase": 1,
        "rightMax": null,
        "rightMin": null
      },
      "gridPos": {
        "h": 7,
        "w": 24,
        "x": 0,
        "y": 14
      },
      "id": 4,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": true,
        "hideZero": true,
        "max": true,
        "min": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "connected",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "/write/",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "hide": false,
          "refCount": 0,
          "refId": "A",
          "target": "alias(collectd.$compute.$uuid.$virt.$diskrw.write, 'read')",
          "textEditor": true
        },
        {
          "hide": false,
          "refCount": 0,
          "refId": "B",
          "target": "alias(collectd.$compute.$uuid.$virt.$diskrw.read, 'write')"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "DISK R/W $uuid",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "x-axis": true,
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "y-axis": true,
      "y_formats": [
        "Bps",
        "Bps"
      ],
      "yaxes": [
        {
          "format": "Bps",
          "label": null,
          "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": "5s",
  "schemaVersion": 20,
  "style": "dark",
  "tags": [
    "openstack",
    "libvirt",
    "kvm"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "compute",
        "options": [],
        "query": "collectd.*",
        "refresh": 1,
        "regex": "//",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allFormat": "glob",
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "collectd.$compute.*",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": false,
        "multiFormat": "glob",
        "name": "uuid",
        "options": [],
        "query": "collectd.$compute.*",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allFormat": "glob",
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "collectd.$compute.$uuid.*",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": false,
        "multiFormat": "glob",
        "name": "virt",
        "options": [],
        "query": "collectd.$compute.$uuid.*",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allFormat": "glob",
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "collectd.$compute.$uuid.$virt.*",
        "hide": 2,
        "includeAll": true,
        "label": null,
        "multi": false,
        "multiFormat": "glob",
        "name": "interface",
        "options": [],
        "query": "collectd.$compute.$uuid.$virt.*",
        "refresh": 1,
        "regex": "/^if_octets*/",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allFormat": "glob",
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "collectd.$compute.$uuid.$virt.*",
        "hide": 2,
        "includeAll": true,
        "label": null,
        "multi": false,
        "multiFormat": "glob",
        "name": "diskrw",
        "options": [],
        "query": "collectd.$compute.$uuid.$virt.*",
        "refresh": 1,
        "regex": "/^disk_octet*/",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allFormat": "glob",
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "collectd.$compute.$uuid.$virt.*",
        "hide": 2,
        "includeAll": true,
        "label": null,
        "multi": false,
        "multiFormat": "glob",
        "name": "diskops",
        "options": [],
        "query": "collectd.$compute.$uuid.$virt.*",
        "refresh": 1,
        "regex": "/^disk_ops/",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAPHITE}",
        "definition": "",
        "hide": 2,
        "includeAll": true,
        "label": null,
        "multi": true,
        "name": "vcpu",
        "options": [],
        "query": "collectd.$compute.$uuid.$virt.*",
        "refresh": 1,
        "regex": "/^virt_vcpu*/",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "Monitoring VMs on OpenStack (or KVM) using Graphite + Collectd",
  "uid": "mqyja-omkqqa",
  "version": 2
}