apiVersion: v1
kind: ConfigMap
metadata:
  name: acc-show-case-dashboard
data:
  dashboard: |-
    {
      "__inputs": [
        {
          "name": "DS_ADS",
          "label": "ads",
          "description": "",
          "type": "datasource",
          "pluginId": "postgres",
          "pluginName": "PostgreSQL"
        }
      ],
      "__requires": [
        {
          "type": "panel",
          "id": "barchart",
          "name": "Bar chart",
          "version": ""
        },
        {
          "type": "grafana",
          "id": "grafana",
          "name": "Grafana",
          "version": "8.1.0"
        },
        {
          "type": "panel",
          "id": "table",
          "name": "Table",
          "version": ""
        },
        {
          "type": "panel",
          "id": "timeseries",
          "name": "Time series",
          "version": ""
        }
      ],
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": "-- Grafana --",
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations & Alerts",
            "target": {
              "limit": 100,
              "matchAny": false,
              "tags": [],
              "type": "dashboard"
            },
            "type": "dashboard"
          }
        ]
      },
      "editable": true,
      "gnetId": null,
      "graphTooltip": 0,
      "id": null,
      "links": [],
      "panels": [
        {
          "datasource": "-- Dashboard --",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "axisSoftMax": 0.5,
                "axisSoftMin": -0.5,
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 10,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "spanNulls": true,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "decimals": 3,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "accG"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 9,
            "w": 15,
            "x": 0,
            "y": 0
          },
          "id": 2,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "hidden",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "pluginVersion": "8.0.6",
          "targets": [
            {
              "panelId": 12,
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Linear Acceleration X",
          "transformations": [
            {
              "id": "filterFieldsByName",
              "options": {
                "include": {
                  "names": [
                    "X",
                    "Time"
                  ]
                }
              }
            }
          ],
          "type": "timeseries"
        },
        {
          "datasource": null,
          "description": "If accelerations are over certain value, the average of 5 second slices are displayed.",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "custom": {
                "align": null,
                "displayMode": "auto",
                "filterable": false
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 18,
            "w": 9,
            "x": 15,
            "y": 0
          },
          "hideTimeOverride": true,
          "id": 8,
          "interval": "5s",
          "options": {
            "frameIndex": 1,
            "showHeader": true
          },
          "pluginVersion": "8.1.0",
          "targets": [
            {
              "format": "time_series",
              "group": [],
              "metricColumn": "none",
              "rawQuery": true,
              "rawSql": "SELECT\n  $__timeGroupAlias(\"time\",5s),\n  max(((payload->>'x')::numeric)) AS \"x-max\",\n  max(((payload->>'y')::numeric)) AS \"y-max\",\n  max(((payload->>'z')::numeric)) AS \"z-max\"\nFROM accmaximumvalues\nWHERE\n  $__timeFilter(\"time\") AND\n  (((payload->>'x')::numeric) > 0.3 or ((payload->>'y')::numeric) > 0.3 or ((payload->>'z')::numeric) > 0.3)\nGROUP BY 1\nORDER BY time",
              "refId": "A",
              "select": [
                [
                  {
                    "params": [
                      "value"
                    ],
                    "type": "column"
                  }
                ]
              ],
              "timeColumn": "time",
              "where": [
                {
                  "name": "$__timeFilter",
                  "params": [],
                  "type": "macro"
                }
              ]
            }
          ],
          "timeFrom": "30m",
          "timeShift": null,
          "title": "Threashold Events (30 min)",
          "transformations": [
            {
              "id": "sortBy",
              "options": {
                "fields": {},
                "sort": [
                  {
                    "desc": true,
                    "field": "Time"
                  }
                ]
              }
            }
          ],
          "type": "table"
        },
        {
          "datasource": "-- Dashboard --",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "axisSoftMax": 0.5,
                "axisSoftMin": -0.5,
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 10,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "spanNulls": true,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "decimals": 3,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "accG"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 9,
            "w": 15,
            "x": 0,
            "y": 9
          },
          "id": 4,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "hidden",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "pluginVersion": "8.0.6",
          "targets": [
            {
              "panelId": 12,
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Linear Acceleration Y",
          "transformations": [
            {
              "id": "filterFieldsByName",
              "options": {
                "include": {
                  "names": [
                    "Time",
                    "Y"
                  ]
                }
              }
            }
          ],
          "type": "timeseries"
        },
        {
          "datasource": "-- Dashboard --",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "axisSoftMax": 0.5,
                "axisSoftMin": -0.5,
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 10,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "spanNulls": true,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "decimals": 3,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "accG"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 9,
            "w": 15,
            "x": 0,
            "y": 18
          },
          "id": 6,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "hidden",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "pluginVersion": "8.0.6",
          "targets": [
            {
              "panelId": 12,
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Linear Acceleration Z",
          "transformations": [
            {
              "id": "filterFieldsByName",
              "options": {
                "include": {
                  "names": [
                    "Time",
                    "Z"
                  ]
                }
              }
            }
          ],
          "type": "timeseries"
        },
        {
          "datasource": null,
          "description": "If accelerations are over certain value, the average of 5 second slices are displayed.",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "left",
                "axisSoftMax": 1,
                "axisSoftMin": 0,
                "fillOpacity": 80,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineWidth": 1
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 9,
            "x": 15,
            "y": 18
          },
          "hideTimeOverride": true,
          "id": 13,
          "options": {
            "barWidth": 0.97,
            "groupWidth": 0.7,
            "legend": {
              "calcs": [],
              "displayMode": "hidden",
              "placement": "bottom"
            },
            "orientation": "auto",
            "showValue": "auto",
            "stacking": "none",
            "text": {},
            "tooltip": {
              "mode": "single"
            }
          },
          "pluginVersion": "8.0.6",
          "targets": [
            {
              "format": "time_series",
              "group": [],
              "metricColumn": "none",
              "rawQuery": true,
              "rawSql": "SELECT\n  $__timeGroupAlias(\"time\",1m),\n  max(((payload->>'x')::numeric)) AS \"X\",\n  max(((payload->>'y')::numeric)) AS \"Y\",\n  max(((payload->>'z')::numeric)) AS \"Z\"\nFROM accmaximumvalues\nWHERE\n  $__timeFilter(\"time\")\nGROUP BY 1\nORDER BY time",
              "refId": "A",
              "select": [
                [
                  {
                    "params": [
                      "value"
                    ],
                    "type": "column"
                  }
                ]
              ],
              "timeColumn": "time",
              "where": [
                {
                  "name": "$__timeFilter",
                  "params": [],
                  "type": "macro"
                }
              ]
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Maximum Values (1 min)",
          "transformations": [
            {
              "id": "sortBy",
              "options": {
                "fields": {},
                "sort": [
                  {
                    "desc": true,
                    "field": "time"
                  }
                ]
              }
            },
            {
              "id": "reduce",
              "options": {
                "reducers": []
              }
            },
            {
              "id": "reduce",
              "options": {
                "reducers": []
              }
            },
            {
              "id": "reduce",
              "options": {
                "reducers": [
                  "max"
                ]
              }
            }
          ],
          "type": "barchart"
        },
        {
          "alert": {
            "alertRuleTags": {},
            "conditions": [
              {
                "evaluator": {
                  "params": [
                    0.15
                  ],
                  "type": "gt"
                },
                "operator": {
                  "type": "and"
                },
                "query": {
                  "params": [
                    "A",
                    "10s",
                    "now"
                  ]
                },
                "reducer": {
                  "params": [],
                  "type": "max"
                },
                "type": "query"
              }
            ],
            "executionErrorState": "alerting",
            "for": "10s",
            "frequency": "10s",
            "handler": 1,
            "message": "Very strong vibration detected.",
            "name": "Acceleration Alert",
            "noDataState": "keep_state",
            "notifications": [
              {
                "uid": "dQ563YVnk"
              },
              {
                "uid": "mj9meY47k"
              }
            ]
          },
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 0,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "auto",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "accG"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 1,
            "w": 9,
            "x": 15,
            "y": 26
          },
          "id": 10,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "hidden",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "format": "time_series",
              "group": [],
              "metricColumn": "none",
              "rawQuery": true,
              "rawSql": "SELECT\n  $__timeGroup(\"time\", '1s'),\n  abs((payload->>'x')::numeric) as x,\n  abs((payload->>'y')::numeric) as y,\n  abs((payload->>'z')::numeric) as z\nFROM demo\nWHERE\n  $__timeFilter(time)\nORDER BY 1,2",
              "refId": "A",
              "select": [
                [
                  {
                    "params": [
                      "value"
                    ],
                    "type": "column"
                  }
                ]
              ],
              "timeColumn": "time",
              "where": [
                {
                  "name": "$__timeFilter",
                  "params": [],
                  "type": "macro"
                }
              ]
            }
          ],
          "thresholds": [
            {
              "colorMode": "critical",
              "op": "gt",
              "value": 0.15,
              "visible": true
            }
          ],
          "title": "Alerting",
          "type": "timeseries"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "drawStyle": "line",
                "fillOpacity": 0,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "lineInterpolation": "linear",
                "lineWidth": 1,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "auto",
                "spanNulls": false,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "decimals": 3,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "accG"
            },
            "overrides": [
              {
                "__systemRef": "hideSeriesFrom",
                "matcher": {
                  "id": "byNames",
                  "options": {
                    "mode": "exclude",
                    "names": [
                      "Z"
                    ],
                    "prefix": "All except:",
                    "readOnly": true
                  }
                },
                "properties": [
                  {
                    "id": "custom.hideFrom",
                    "value": {
                      "legend": false,
                      "tooltip": false,
                      "viz": true
                    }
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 1,
            "w": 15,
            "x": 0,
            "y": 27
          },
          "id": 12,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "hidden",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "single"
            }
          },
          "targets": [
            {
              "format": "time_series",
              "group": [],
              "metricColumn": "none",
              "rawQuery": true,
              "rawSql": "SELECT\n  time AS \"time\",\n  (payload->>'x')::numeric AS \"X\",\n  (payload->>'y')::numeric AS \"Y\",\n  (payload->>'z')::numeric AS \"Z\"\nFROM demo\nWHERE\n  $__timeFilter(time)\nORDER BY 1",
              "refId": "A",
              "select": [
                [
                  {
                    "params": [
                      "value"
                    ],
                    "type": "column"
                  }
                ]
              ],
              "timeColumn": "time",
              "where": [
                {
                  "name": "$__timeFilter",
                  "params": [],
                  "type": "macro"
                }
              ]
            }
          ],
          "title": "Source panel",
          "type": "timeseries"
        }
      ],
      "refresh": "1s",
      "schemaVersion": 30,
      "style": "dark",
      "tags": [],
      "templating": {
        "list": []
      },
      "time": {
        "from": "now-30s",
        "to": "now"
      },
      "timepicker": {
        "refresh_intervals": [
          "500ms",
          "1s",
          "5s",
          "10s",
          "30s",
          "1m",
          "5m",
          "15m",
          "30m",
          "1h"
        ]
      },
      "timezone": "",
      "title": "Accelerator Show Case",
      "uid": "cc3077d2f990cd0adc5ddb17de46f347c43279a0",
      "version": 5
    }
