Host-agnostic compute queries

Cherry-picked from: Iead34feb057824860d1c3ef64a98e9443d1a2b28
Related-bug: PROD-30600 (PROD:30600)

Change-Id: I07600f37676e7d1dfdace1931e6f0122a8cfaa02
diff --git a/prometheus/files/grafana_dashboards/provisioning_kpi_prometheus.json b/prometheus/files/grafana_dashboards/kpi_provisioning_prometheus.json
similarity index 91%
rename from prometheus/files/grafana_dashboards/provisioning_kpi_prometheus.json
rename to prometheus/files/grafana_dashboards/kpi_provisioning_prometheus.json
index dd8b032..c532982 100644
--- a/prometheus/files/grafana_dashboards/provisioning_kpi_prometheus.json
+++ b/prometheus/files/grafana_dashboards/kpi_provisioning_prometheus.json
@@ -33,260 +33,6 @@
     },
     {
       "cacheTimeout": null,
-      "colorBackground": false,
-      "colorValue": false,
-      "colors": [
-        "#299c46",
-        "rgba(237, 129, 40, 0.89)",
-        "#d44a3a"
-      ],
-      "datasource": null,
-      "format": "none",
-      "gauge": {
-        "maxValue": 100,
-        "minValue": 0,
-        "show": false,
-        "thresholdLabels": false,
-        "thresholdMarkers": true
-      },
-      "gridPos": {
-        "h": 6,
-        "w": 3,
-        "x": 0,
-        "y": 1
-      },
-      "hideTimeOverride": true,
-      "id": 10,
-      "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": "",
-      "targets": [
-        {
-          "expr": "sum(compute_instance_create_start_host_doc_count)",
-          "format": "time_series",
-          "interval": "30s",
-          "intervalFactor": 1,
-          "legendFormat": "",
-          "refId": "A"
-        }
-      ],
-      "thresholds": "",
-      "timeFrom": "30s",
-      "title": "Start",
-      "type": "singlestat",
-      "valueFontSize": "80%",
-      "valueMaps": [
-        {
-          "op": "=",
-          "text": "0",
-          "value": "null"
-        }
-      ],
-      "valueName": "current"
-    },
-    {
-      "cacheTimeout": null,
-      "colorBackground": false,
-      "colorValue": false,
-      "colors": [
-        "#299c46",
-        "rgba(237, 129, 40, 0.89)",
-        "#d44a3a"
-      ],
-      "datasource": null,
-      "format": "none",
-      "gauge": {
-        "maxValue": 100,
-        "minValue": 0,
-        "show": false,
-        "thresholdLabels": false,
-        "thresholdMarkers": true
-      },
-      "gridPos": {
-        "h": 6,
-        "w": 3,
-        "x": 3,
-        "y": 1
-      },
-      "hideTimeOverride": true,
-      "id": 11,
-      "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": "",
-      "targets": [
-        {
-          "expr": "sum(compute_instance_create_end_host_doc_count)",
-          "format": "time_series",
-          "interval": "",
-          "intervalFactor": 1,
-          "legendFormat": "",
-          "refId": "A"
-        }
-      ],
-      "thresholds": "",
-      "timeFrom": "30s",
-      "timeShift": null,
-      "title": "End",
-      "type": "singlestat",
-      "valueFontSize": "80%",
-      "valueMaps": [
-        {
-          "op": "=",
-          "text": "N/A",
-          "value": "null"
-        }
-      ],
-      "valueName": "current"
-    },
-    {
-      "cacheTimeout": null,
-      "colorBackground": true,
-      "colorValue": false,
-      "colors": [
-        "#299c46",
-        "rgba(237, 129, 40, 0.89)",
-        "#d44a3a"
-      ],
-      "datasource": null,
-      "format": "none",
-      "gauge": {
-        "maxValue": 100,
-        "minValue": 0,
-        "show": false,
-        "thresholdLabels": false,
-        "thresholdMarkers": true
-      },
-      "gridPos": {
-        "h": 6,
-        "w": 3,
-        "x": 6,
-        "y": 1
-      },
-      "hideTimeOverride": true,
-      "id": 12,
-      "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": "",
-      "targets": [
-        {
-          "expr": "sum(compute_instance_create_error_host_doc_count)",
-          "format": "time_series",
-          "hide": false,
-          "intervalFactor": 1,
-          "legendFormat": "",
-          "refId": "A"
-        }
-      ],
-      "thresholds": "1",
-      "timeFrom": "30s",
-      "timeShift": null,
-      "title": "Error",
-      "type": "singlestat",
-      "valueFontSize": "80%",
-      "valueMaps": [
-        {
-          "op": "=",
-          "text": "0",
-          "value": "null"
-        }
-      ],
-      "valueName": "current"
-    },
-    {
-      "cacheTimeout": null,
       "colorBackground": true,
       "colorValue": false,
       "colors": [
@@ -304,9 +50,9 @@
         "thresholdMarkers": true
       },
       "gridPos": {
-        "h": 6,
-        "w": 3,
-        "x": 9,
+        "h": 3,
+        "w": 4,
+        "x": 0,
         "y": 1
       },
       "hideTimeOverride": true,
@@ -347,16 +93,16 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "1 - sum(compute_instance_create_error_host_doc_count) / sum(compute_instance_create_start_host_doc_count)",
+          "expr": "1 - sum(compute_instance_create_error_event_doc_count) / sum(compute_instance_create_start_event_doc_count)",
           "format": "time_series",
           "intervalFactor": 1,
           "legendFormat": "",
           "refId": "A"
         }
       ],
-      "thresholds": "0.5,0.8",
+      "thresholds": "0.9,0.98",
       "timeFrom": "30s",
-      "title": "VM creation success",
+      "title": "KPI 1 - VM provisioning %",
       "type": "singlestat",
       "valueFontSize": "80%",
       "valueMaps": [
@@ -369,16 +115,270 @@
       "valueName": "current"
     },
     {
+      "cacheTimeout": null,
+      "colorBackground": false,
+      "colorValue": false,
+      "colors": [
+        "#299c46",
+        "rgba(237, 129, 40, 0.89)",
+        "#d44a3a"
+      ],
+      "datasource": null,
+      "format": "none",
+      "gauge": {
+        "maxValue": 100,
+        "minValue": 0,
+        "show": false,
+        "thresholdLabels": false,
+        "thresholdMarkers": true
+      },
+      "gridPos": {
+        "h": 3,
+        "w": 3,
+        "x": 4,
+        "y": 1
+      },
+      "hideTimeOverride": true,
+      "id": 10,
+      "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": "",
+      "targets": [
+        {
+          "expr": "sum(compute_instance_create_start_event_doc_count)",
+          "format": "time_series",
+          "interval": "30s",
+          "intervalFactor": 1,
+          "legendFormat": "",
+          "refId": "A"
+        }
+      ],
+      "thresholds": "",
+      "timeFrom": "30s",
+      "title": "Start",
+      "type": "singlestat",
+      "valueFontSize": "80%",
+      "valueMaps": [
+        {
+          "op": "=",
+          "text": "0",
+          "value": "null"
+        }
+      ],
+      "valueName": "current"
+    },
+    {
+      "cacheTimeout": null,
+      "colorBackground": false,
+      "colorValue": false,
+      "colors": [
+        "#299c46",
+        "rgba(237, 129, 40, 0.89)",
+        "#d44a3a"
+      ],
+      "datasource": null,
+      "format": "none",
+      "gauge": {
+        "maxValue": 100,
+        "minValue": 0,
+        "show": false,
+        "thresholdLabels": false,
+        "thresholdMarkers": true
+      },
+      "gridPos": {
+        "h": 3,
+        "w": 3,
+        "x": 7,
+        "y": 1
+      },
+      "hideTimeOverride": true,
+      "id": 11,
+      "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": "",
+      "targets": [
+        {
+          "expr": "sum(compute_instance_create_end_event_doc_count)",
+          "format": "time_series",
+          "interval": "",
+          "intervalFactor": 1,
+          "legendFormat": "",
+          "refId": "A"
+        }
+      ],
+      "thresholds": "",
+      "timeFrom": "30s",
+      "timeShift": null,
+      "title": "End",
+      "type": "singlestat",
+      "valueFontSize": "80%",
+      "valueMaps": [
+        {
+          "op": "=",
+          "text": "0",
+          "value": "null"
+        }
+      ],
+      "valueName": "current"
+    },
+    {
+      "cacheTimeout": null,
+      "colorBackground": true,
+      "colorValue": false,
+      "colors": [
+        "#299c46",
+        "rgba(237, 129, 40, 0.89)",
+        "#d44a3a"
+      ],
+      "datasource": null,
+      "format": "none",
+      "gauge": {
+        "maxValue": 100,
+        "minValue": 0,
+        "show": false,
+        "thresholdLabels": false,
+        "thresholdMarkers": true
+      },
+      "gridPos": {
+        "h": 3,
+        "w": 3,
+        "x": 10,
+        "y": 1
+      },
+      "hideTimeOverride": true,
+      "id": 12,
+      "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": "",
+      "targets": [
+        {
+          "expr": "sum(compute_instance_create_error_event_doc_count)",
+          "format": "time_series",
+          "hide": false,
+          "intervalFactor": 1,
+          "legendFormat": "",
+          "refId": "A"
+        }
+      ],
+      "thresholds": "1",
+      "timeFrom": "30s",
+      "timeShift": null,
+      "title": "Error",
+      "type": "singlestat",
+      "valueFontSize": "80%",
+      "valueMaps": [
+        {
+          "op": "=",
+          "text": "0",
+          "value": "null"
+        }
+      ],
+      "valueName": "current"
+    },
+    {
       "collapsed": false,
       "gridPos": {
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 7
+        "y": 4
       },
       "id": 15,
       "panels": [],
-      "title": "Daily (measured over the last 24h)",
+      "title": "Daily instance provisioning (24h)",
       "type": "row"
     },
     {
@@ -392,7 +392,7 @@
         "h": 8,
         "w": 24,
         "x": 0,
-        "y": 8
+        "y": 5
       },
       "id": 8,
       "legend": {
@@ -449,7 +449,7 @@
             }
           ],
           "dsType": "elasticsearch",
-          "expr": "sum(compute_instance_create_start_host_doc_count)",
+          "expr": "sum(compute_instance_create_start_event_doc_count)",
           "format": "time_series",
           "interval": "1d",
           "intervalFactor": 2,
@@ -480,7 +480,7 @@
             }
           ],
           "dsType": "elasticsearch",
-          "expr": "sum(compute_instance_create_end_host_doc_count)",
+          "expr": "sum(compute_instance_create_end_event_doc_count)",
           "format": "time_series",
           "interval": "1d",
           "intervalFactor": 2,
@@ -511,7 +511,7 @@
             }
           ],
           "dsType": "elasticsearch",
-          "expr": "sum(compute_instance_create_error_host_doc_count)",
+          "expr": "sum(compute_instance_create_error_event_doc_count)",
           "format": "time_series",
           "instant": false,
           "interval": "1d",
@@ -532,7 +532,7 @@
       "thresholds": [],
       "timeFrom": null,
       "timeShift": null,
-      "title": "VM instances",
+      "title": "Number of created VMs",
       "tooltip": {
         "shared": true,
         "sort": 0,
@@ -552,7 +552,7 @@
           "label": null,
           "logBase": 1,
           "max": null,
-          "min": null,
+          "min": "0",
           "show": true
         },
         {
@@ -580,7 +580,7 @@
         "h": 8,
         "w": 24,
         "x": 0,
-        "y": 16
+        "y": 13
       },
       "id": 3,
       "legend": {
@@ -635,7 +635,7 @@
             }
           ],
           "dsType": "elasticsearch",
-          "expr": "1 - sum(compute_instance_create_error_host_doc_count) / (sum(compute_instance_create_start_host_doc_count > 0) or count(compute_instance_create_start_host_doc_count == 0))",
+          "expr": "1 - sum(compute_instance_create_error_event_doc_count) / (sum(compute_instance_create_start_event_doc_count > 0) or count(compute_instance_create_start_event_doc_count == 0))",
           "format": "time_series",
           "instant": false,
           "interval": "1d",
@@ -656,7 +656,7 @@
       "thresholds": [],
       "timeFrom": null,
       "timeShift": null,
-      "title": "VM creation success",
+      "title": "KPI 1 - VM provisioning %",
       "tooltip": {
         "shared": true,
         "sort": 0,
@@ -672,11 +672,12 @@
       },
       "yaxes": [
         {
+          "decimals": 1,
           "format": "percentunit",
           "label": null,
           "logBase": 1,
-          "max": null,
-          "min": null,
+          "max": "1",
+          "min": "0",
           "show": true
         },
         {
@@ -731,7 +732,7 @@
     ]
   },
   "timezone": "",
-  "title": "Provisioning KPI",
-  "version": 1
+  "title": "KPI - Provisioning",
+  "version": 2
 }
 {%- endraw %}
diff --git a/prometheus/meta/grafana.yml b/prometheus/meta/grafana.yml
index f3bcb3b..21b83bd 100644
--- a/prometheus/meta/grafana.yml
+++ b/prometheus/meta/grafana.yml
@@ -31,8 +31,8 @@
     template: prometheus/files/grafana_dashboards/relay_prometheus.json
 {%- endif %}
 {%- if elasticsearch_exporter.get('enabled', False) and pillar._param.openstack_version is defined %}
-  provisioning_kpi_prometheus:
+  kpi_provisioning_prometheus:
     datasource: prometheus
     format: json
-    template: prometheus/files/grafana_dashboards/provisioning_kpi_prometheus.json
+    template: prometheus/files/grafana_dashboards/kpi_provisioning_prometheus.json
 {%- endif %}