{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana-athena-datasource",
		  "uid": "Amazon Athena"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Single-panel dashboard for visualizing any CAN/LIN data via the Athena data source",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "id": 53,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "grafana-athena-datasource",
		"uid": "Amazon Athena"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 1,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": 300000,
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 2,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "always",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "_col1"
            },
            "properties": [
              {
                "id": "mappings",
                "value": []
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 15,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 5,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "connectionArgs": {
            "catalog": "__default",
            "database": "__default",
            "region": "__default",
            "resultReuseEnabled": true,
            "resultReuseMaxAgeInMinutes": 60
          },
          "datasource": {
            "type": "grafana-athena-datasource",
			"uid": "Amazon Athena"
          },
          "format": 1,
          "rawSQL": "SELECT\r\n    $__timeGroup(t, $__interval) as time,\r\n    ${signal_value:csv}\r\nFROM\r\n    tbl_${device:csv}_${message:csv}\r\nWHERE\r\n\tdate_created BETWEEN $__rawTimeFrom('yyyy/MM/dd') AND $__rawTimeTo('yyyy/MM/dd') \r\n\tAND\r\n    $__timeFilter(t)\r\nGROUP BY\r\n    $__timeGroup(t, $__interval)\r\nORDER BY\r\n\ttime asc",
          "refId": "A"
        }
      ],
      "title": "message: ${message:csv} | signal: ${signal}",
      "transformations": [
        {
          "id": "filterFieldsByName",
          "options": {
            "include": {
              "pattern": "/^(${aggregation:pipe})_.*|^time$/"
            }
          }
        }
      ],
      "type": "timeseries"
    }
  ],
  "refresh": "",
  "schemaVersion": 38,
  "tags": [
    "athena"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": true
        },
        "datasource": {
          "type": "grafana-athena-datasource",
		  "uid": "Amazon Athena"
        },
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "device",
        "options": [],
        "query": {
          "connectionArgs": {
            "catalog": "__default",
            "database": "__default",
            "region": "__default",
            "resultReuseEnabled": false,
            "resultReuseMaxAgeInMinutes": 60
          },
          "format": 1,
          "rawSQL": "SELECT deviceid AS value, metaname AS text\r\nFROM tbl_aggregations_devicemeta\r\nWHERE date_created = '2024/01/01' ORDER BY metaname"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": true
        },
        "datasource": {
          "type": "grafana-athena-datasource",
		  "uid": "Amazon Athena"
        },
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "message",
        "options": [],
        "query": {
          "connectionArgs": {
            "catalog": "__default",
            "database": "__default",
            "region": "__default",
            "resultReuseEnabled": false,
            "resultReuseMaxAgeInMinutes": 60
          },
          "format": 1,
          "rawSQL": "SELECT MessageName\r\nFROM tbl_${device}_messages\r\nWHERE date_created = '2024/01/01' AND MessageName <> 'messages' ORDER BY MessageName"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": true
        },
        "datasource": {
          "type": "grafana-athena-datasource",
		  "uid": "Amazon Athena"
        },
        "definition": "",
        "hide": 0,
        "includeAll": true,
        "multi": true,
        "name": "signal",
        "options": [],
        "query": {
          "connectionArgs": {
            "catalog": "__default",
            "database": "__default",
            "region": "__default",
            "resultReuseEnabled": true,
            "resultReuseMaxAgeInMinutes": 60
          },
          "format": 1,
          "rawSQL": "SHOW COLUMNS IN `tbl_${device:csv}_${message:csv}`"
        },
        "refresh": 1,
        "regex": "/^(?!date_created\\s|t\\s).*$/",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "datasource": {
          "type": "grafana-athena-datasource",
		  "uid": "Amazon Athena"
        },
        "definition": "",
        "hide": 2,
        "includeAll": true,
        "multi": true,
        "name": "signal_value",
        "options": [],
        "query": {
          "connectionArgs": {
            "catalog": "__default",
            "database": "__default",
            "region": "__default",
            "resultReuseEnabled": true,
            "resultReuseMaxAgeInMinutes": 60
          },
          "format": 1,
          "rawSQL": "SELECT \r\n    array_join(\r\n        concat(\r\n            transform(split('${signal:csv}', ','), x -> 'AVG(' || REPLACE(x, ' ', '') || ') AS AVG_' || x),\r\n            transform(split('${signal:csv}', ','), x -> 'MIN(' || REPLACE(x, ' ', '') || ') AS MIN_' || x),\r\n            transform(split('${signal:csv}', ','), x -> 'MAX(' || REPLACE(x, ' ', '') || ') AS MAX_' || x)\r\n        ),\r\n        ', '\r\n    );"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": true,
          "text": [
            "AVG"
          ],
          "value": [
            "AVG"
          ]
        },
        "hide": 0,
        "includeAll": true,
        "multi": true,
        "name": "aggregation",
        "options": [
          {
            "selected": false,
            "text": "All",
            "value": "$__all"
          },
          {
            "selected": true,
            "text": "AVG",
            "value": "AVG"
          },
          {
            "selected": false,
            "text": "MIN",
            "value": "MIN"
          },
          {
            "selected": false,
            "text": "MAX",
            "value": "MAX"
          }
        ],
        "query": "AVG, MIN, MAX",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-90d",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "athena-dynamic-dashboard",
  "uid": "athena-dynamic-dashboard-1",
  "version": 102,
  "weekStart": ""
}