Grafana dashboard: Decision Evaluation KPI Summary (Prometheus)
Description: Default dashboard for monitoring real-time KPI definitions from SMARTS.

# Decision Key Performance Indicator (KPI) Metrics

This dashboard is for use with Sparkling Logic SMARTS(tm) Decision Services and the real-time KPI feature of SMARTS.

If you have real-time KPI metrics defined in SMARTS and deployed through the deployment manager then the metric values can be exposed through Prometheus.
This dashboard just shows the raw values as provided by the SMARTS KPI and can be further customized to show multiple KPIs at the same time.

In addition to the metric values it shows the number of alerts. These are alerts as defined by the SMARTS KPI. You can also specify alerts as part of the deployment.

## SMARTS Configuration
If you deployed SMARTS using a helm chart, then you can easily enable your deployment for metrics scraping as follows:
```
configuration:
    metrics:
      decision_evaluation: true
      decision_metrics: true
metrics:
  enabled: true
  serviceMonitor:
    enabled: true
```
## Prometheus Configuration
If you are using a Prometheus Server then you may need to configure this server to `remote write` your metrics to Grafana.
For example:
```
prometheus:
  prometheusSpec:
    remoteWrite:
    - url: "https://prometheus-blocks-prod-us-central1.grafana.net/api/prom/push"
      basicAuth:
          username:
            name: grafanasecret
            key: username
          password:
            name: grafanasecret
            key: password
```

{
  "__inputs": [
    {
      "name": "DS_GRAFANACLOUD-SPLOG-PROM",
      "label": "grafanacloud-splog-prom",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.5.7"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Default dashboard for monitoring real-time KPI definitions from SMARTS.",
  "editable": true,
  "gnetId": 14645,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1623945856524,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 15,
        "x": 0,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 2,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "connected",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.7",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "exemplar": true,
          "expr": "sum by (kpi, agg, grp) (rate(sl_decision_evaluation_kpi {pod=~\"$instances\", workspace=~\"$workspaces\", deployment=~\"$deployments\", decision=~\"$decisions\", kpi=\"$kpi\"}[$__rate_interval]))",
          "interval": "",
          "legendFormat": "{{kpi}}-{{grp}}-{{agg}}",
          "queryType": "randomWalk",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Decision KPI",
      "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
      }
    },
    {
      "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "rgb(108, 112, 108)",
                "value": null
              },
              {
                "color": "red",
                "value": 5
              }
            ]
          },
          "unit": "notifications"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 3,
        "w": 4,
        "x": 15,
        "y": 0
      },
      "id": 4,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {
          "valueSize": 20
        },
        "textMode": "auto"
      },
      "pluginVersion": "7.5.7",
      "targets": [
        {
          "exemplar": true,
          "expr": "sum by (kpi, notification) (increase(sl_decision_evaluation_kpi_notification_total {pod=~\"$instances\", workspace=~\"$workspaces\", deployment=~\"$deployments\", decision=~\"$decisions\", kpi=\"$kpi\"}[$__range]))",
          "interval": "",
          "legendFormat": "{{kpi}}-{{notification}}",
          "queryType": "randomWalk",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Notifications",
      "type": "stat"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 27,
  "style": "dark",
  "tags": [
    "sparklinglogic",
    "smarts"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
        "definition": "label_values(sl_decision_evaluation_kpi, pod)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Instances",
        "multi": true,
        "name": "instances",
        "options": [],
        "query": {
          "query": "label_values(sl_decision_evaluation_kpi, pod)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
        "definition": "label_values(sl_decision_evaluation_kpi { pod=~\"$instances\"}, workspace)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Workspaces",
        "multi": true,
        "name": "workspaces",
        "options": [],
        "query": {
          "query": "label_values(sl_decision_evaluation_kpi { pod=~\"$instances\"}, workspace)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
        "definition": "label_values(sl_decision_evaluation_kpi { pod=~\"$instances\", workspace=~\"$workspaces\"}, deployment)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Deployments",
        "multi": true,
        "name": "deployments",
        "options": [],
        "query": {
          "query": "label_values(sl_decision_evaluation_kpi { pod=~\"$instances\", workspace=~\"$workspaces\"}, deployment)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
        "definition": "label_values(sl_decision_evaluation_kpi {pod=~\"$instances\", workspace=~\"$workspaces\", deployment=~\"$deployments\"}, decision)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Decisions",
        "multi": true,
        "name": "decisions",
        "options": [],
        "query": {
          "query": "label_values(sl_decision_evaluation_kpi {pod=~\"$instances\", workspace=~\"$workspaces\", deployment=~\"$deployments\"}, decision)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_GRAFANACLOUD-SPLOG-PROM}",
        "definition": "label_values(sl_decision_evaluation_kpi {pod=~\"$instances\", workspace=~\"$workspaces\", deployment=~\"$deployments\", decision=~\"$decisions\"}, kpi)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "KPI",
        "multi": false,
        "name": "kpi",
        "options": [],
        "query": {
          "query": "label_values(sl_decision_evaluation_kpi {pod=~\"$instances\", workspace=~\"$workspaces\", deployment=~\"$deployments\", decision=~\"$decisions\"}, kpi)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Decision Evaluation KPI Summary (Prometheus)",
  "uid": "5lehNDg7z",
  "version": 11
}