---
apiVersion: v1
kind: ConfigMap
metadata:
  name: slo
  labels:
    grafana_dashboard: "1"
data:
  slo.json: |-
    {
      "__requires": [
        {
          "type": "grafana",
          "id": "grafana",
          "name": "Grafana",
          "version": "5.3.2"
        },
        {
          "type": "panel",
          "id": "graph",
          "name": "Graph",
          "version": "5.0.0"
        },
        {
          "type": "datasource",
          "id": "prometheus",
          "name": "Prometheus",
          "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": "Service level dashboard with availability and error budgets based on the Kubernetes service-lebel-operator",
      "editable": true,
      "gnetId": 8793,
      "graphTooltip": 0,
      "id": null,
      "iteration": 1541323644535,
      "links": [],
      "panels": [
        {
          "collapsed": false,
          "gridPos": {
            "h": 1,
            "w": 24,
            "x": 0,
            "y": 0
          },
          "id": 10,
          "panels": [],
          "repeat": "slo",
          "title": "${service_level}/${slo}",
          "type": "row"
        },
        {
          "aliasColors": {},
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "Thanos",
          "description": "The availability % of the selected SLO",
          "fill": 2,
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 1
          },
          "id": 2,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": false,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "null",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "/availability % - .*/",
              "color": "#ffffff",
              "dashes": true,
              "fill": 0
            },
            {
              "alias": "availability %",
              "color": "#65c5db"
            }
          ],
          "spaceLength": 10,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "expr": "(1-\n  (\n    sum(rate(service_level_sli_result_error_ratio_total{service_level=\"${service_level}\", slo=\"${slo}\"}[${interval}]))\n    /\n    sum(rate(service_level_sli_result_count_total{service_level=\"${service_level}\", slo=\"${slo}\"}[${interval}]))\n  )\n) * 100",
              "format": "time_series",
              "intervalFactor": 1,
              "legendFormat": "availability %",
              "refId": "A"
            },
            {
              "expr": "(1-\n  (\n    sum(rate(service_level_sli_result_error_ratio_total{service_level=\"${service_level}\", slo=\"${slo}\"}[${interval}] offset ${offset}))\n    /\n    sum(rate(service_level_sli_result_count_total{service_level=\"${service_level}\", slo=\"${slo}\"}[${interval}] offset ${offset}))\n  )\n) * 100",
              "format": "time_series",
              "intervalFactor": 1,
              "legendFormat": "availability % - ${offset}",
              "refId": "B"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Service level compliance",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "transparent": false,
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "decimals": 2,
              "format": "percent",
              "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": "Thanos",
          "description": "The burn rate for the error budget with a threshold that marks the max burn rate that can happen to not burn the budget",
          "fill": 2,
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 9
          },
          "id": 14,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "null",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [
            {
              "alias": "max budget",
              "color": "#cca300",
              "fill": 0
            },
            {
              "alias": "budget burn rate",
              "color": "#806eb7",
              "zindex": 1
            },
            {
              "alias": "/.*/",
              "hideTooltip": true
            }
          ],
          "spaceLength": 10,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "expr": "increase(service_level_sli_result_error_ratio_total{service_level=\"${service_level}\", slo=\"${slo}\"}[${interval}])",
              "format": "time_series",
              "intervalFactor": 1,
              "legendFormat": "budget burn rate",
              "refId": "A"
            },
            {
              "expr": "(\n  1 - service_level_slo_objective_ratio{service_level=\"${service_level}\", slo=\"${slo}\"}\n) * increase(service_level_sli_result_count_total{service_level=\"${service_level}\", slo=\"${slo}\"}[${interval}])",
              "format": "time_series",
              "intervalFactor": 1,
              "legendFormat": "max budget",
              "refId": "B"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeShift": null,
          "title": "Error budget burn rate",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "transparent": false,
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "decimals": 5,
              "format": "none",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": false
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ],
          "yaxis": {
            "align": false,
            "alignLevel": null
          }
        }
      ],
      "refresh": "10s",
      "schemaVersion": 16,
      "style": "dark",
      "tags": [
        "slo",
        "service_level",
        "sli",
        "error_budget",
        "reliability",
        "availability"
      ],
      "templating": {
        "list": [
          {
            "auto": true,
            "auto_count": 1,
            "auto_min": "10s",
            "current": {
              "text": "auto",
              "value": "$__auto_interval_range"
            },
            "hide": 2,
            "label": null,
            "name": "range",
            "options": [
              {
                "selected": true,
                "text": "auto",
                "value": "$__auto_interval_range"
              },
              {
                "selected": false,
                "text": "1d",
                "value": "1d"
              }
            ],
            "query": "1d",
            "refresh": 2,
            "skipUrlSync": false,
            "type": "interval"
          },
          {
            "allValue": null,
            "current": {},
            "datasource": "Thanos",
            "hide": 0,
            "includeAll": false,
            "label": null,
            "multi": false,
            "name": "service_level",
            "options": [],
            "query": "label_values(service_level_slo_objective_ratio, service_level)",
            "refresh": 2,
            "regex": "",
            "skipUrlSync": false,
            "sort": 0,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": false
          },
          {
            "allValue": null,
            "current": {},
            "datasource": "Thanos",
            "hide": 0,
            "includeAll": true,
            "label": null,
            "multi": true,
            "name": "slo",
            "options": [],
            "query": "label_values(service_level_slo_objective_ratio{service_level=\"${service_level}\"}, slo)",
            "refresh": 2,
            "regex": "",
            "skipUrlSync": false,
            "sort": 1,
            "tagValuesQuery": "",
            "tags": [],
            "tagsQuery": "",
            "type": "query",
            "useTags": true
          },
          {
            "auto": false,
            "auto_count": 30,
            "auto_min": "10s",
            "current": {
              "text": "7d",
              "value": "7d"
            },
            "hide": 0,
            "label": "",
            "name": "offset",
            "options": [
              {
                "selected": false,
                "text": "1h",
                "value": "1h"
              },
              {
                "selected": false,
                "text": "1d",
                "value": "1d"
              },
              {
                "selected": false,
                "text": "2d",
                "value": "2d"
              },
              {
                "selected": true,
                "text": "7d",
                "value": "7d"
              },
              {
                "selected": false,
                "text": "14d",
                "value": "14d"
              },
              {
                "selected": false,
                "text": "30d",
                "value": "30d"
              }
            ],
            "query": "1h, 1d, 2d, 7d, 14d, 30d",
            "refresh": 2,
            "skipUrlSync": false,
            "type": "interval"
          },
          {
            "auto": true,
            "auto_count": 50,
            "auto_min": "1m",
            "current": {
              "text": "auto",
              "value": "$__auto_interval_interval"
            },
            "hide": 2,
            "label": null,
            "name": "interval",
            "options": [
              {
                "selected": true,
                "text": "auto",
                "value": "$__auto_interval_interval"
              },
              {
                "selected": false,
                "text": "1m",
                "value": "1m"
              },
              {
                "selected": false,
                "text": "10m",
                "value": "10m"
              },
              {
                "selected": false,
                "text": "30m",
                "value": "30m"
              },
              {
                "selected": false,
                "text": "1h",
                "value": "1h"
              },
              {
                "selected": false,
                "text": "6h",
                "value": "6h"
              },
              {
                "selected": false,
                "text": "12h",
                "value": "12h"
              },
              {
                "selected": false,
                "text": "1d",
                "value": "1d"
              },
              {
                "selected": false,
                "text": "7d",
                "value": "7d"
              },
              {
                "selected": false,
                "text": "14d",
                "value": "14d"
              },
              {
                "selected": false,
                "text": "30d",
                "value": "30d"
              }
            ],
            "query": "1m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
            "refresh": 2,
            "skipUrlSync": false,
            "type": "interval"
          }
        ]
      },
      "time": {
        "from": "now-2d",
        "to": "now"
      },
      "timepicker": {
        "refresh_intervals": [
          "5s",
          "10s",
          "30s",
          "1m",
          "5m",
          "15m",
          "30m",
          "1h",
          "2h",
          "1d"
        ],
        "time_options": [
          "5m",
          "15m",
          "1h",
          "6h",
          "12h",
          "24h",
          "2d",
          "7d",
          "30d"
        ]
      },
      "timezone": "",
      "title": "Service level (SLI/SLO)",
      "uid": "service-level",
      "version": 1
    }
