Simplify Dawarich Grafana dashboard query model

This commit is contained in:
2026-06-22 20:12:14 +02:00
parent b8d9bba5d3
commit f318d80477
2 changed files with 58 additions and 314 deletions
+29 -157
View File
@@ -46,24 +46,7 @@
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT\n now() AS \"time\",\n count(*)::double precision AS points\nFROM points\nWHERE timestamp >= extract(epoch from now() - interval '30 days')::integer\n AND timestamp <= extract(epoch from now())::integer\n AND lonlat IS NOT NULL;",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "SELECT\n now() AS \"time\",\n count(*)::double precision AS points\nFROM points\nWHERE timestamp >= extract(epoch from now() - interval '30 days')::integer\n AND timestamp <= extract(epoch from now())::integer\n AND lonlat IS NOT NULL;"
}
],
"fieldConfig": {
@@ -91,12 +74,13 @@
"calcs": [
"lastNotNull"
],
"fields": "",
"fields": "points",
"values": false
},
"textMode": "auto",
"wideLayout": true
}
},
"pluginVersion": "13.0.2"
},
{
"id": 11,
@@ -122,24 +106,7 @@
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT\n now() AS \"time\",\n round(coalesce(sum(distance), 0)::numeric / 1000.0, 2)::double precision AS km\nFROM tracks\nWHERE start_at >= now() - interval '30 days';",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "SELECT\n now() AS \"time\",\n round(coalesce(sum(distance), 0)::numeric / 1000.0, 2)::double precision AS km\nFROM tracks\nWHERE start_at >= now() - interval '30 days';"
}
],
"fieldConfig": {
@@ -167,12 +134,13 @@
"calcs": [
"lastNotNull"
],
"fields": "",
"fields": "km",
"values": false
},
"textMode": "auto",
"wideLayout": true
}
},
"pluginVersion": "13.0.2"
},
{
"id": 12,
@@ -198,24 +166,7 @@
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT\n now() AS \"time\",\n count(*)::double precision AS tracks\nFROM tracks\nWHERE start_at >= now() - interval '30 days';",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "SELECT\n now() AS \"time\",\n count(*)::double precision AS tracks\nFROM tracks\nWHERE start_at >= now() - interval '30 days';"
}
],
"fieldConfig": {
@@ -243,12 +194,13 @@
"calcs": [
"lastNotNull"
],
"fields": "",
"fields": "tracks",
"values": false
},
"textMode": "auto",
"wideLayout": true
}
},
"pluginVersion": "13.0.2"
},
{
"id": 13,
@@ -274,24 +226,7 @@
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT\n now() AS \"time\",\n count(*)::double precision AS anomalies\nFROM points\nWHERE timestamp >= extract(epoch from now() - interval '30 days')::integer\n AND timestamp <= extract(epoch from now())::integer\n AND anomaly IS TRUE;",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "SELECT\n now() AS \"time\",\n count(*)::double precision AS anomalies\nFROM points\nWHERE timestamp >= extract(epoch from now() - interval '30 days')::integer\n AND timestamp <= extract(epoch from now())::integer\n AND anomaly IS TRUE;"
}
],
"fieldConfig": {
@@ -323,12 +258,13 @@
"calcs": [
"lastNotNull"
],
"fields": "",
"fields": "anomalies",
"values": false
},
"textMode": "auto",
"wideLayout": true
}
},
"pluginVersion": "13.0.2"
},
{
"id": 1,
@@ -354,24 +290,7 @@
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n to_timestamp(timestamp) AS \"time\",\n ST_Y(lonlat::geometry)::double precision AS lat,\n ST_X(lonlat::geometry)::double precision AS lon,\n accuracy::double precision AS accuracy,\n coalesce(tracker_id, 'unknown') AS tracker\nFROM points\nWHERE timestamp >= extract(epoch from now() - interval '30 days')::integer\n AND timestamp <= extract(epoch from now())::integer\n AND lonlat IS NOT NULL\nORDER BY timestamp DESC\nLIMIT 5000;",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "SELECT\n to_timestamp(timestamp) AS \"time\",\n ST_Y(lonlat::geometry)::double precision AS lat,\n ST_X(lonlat::geometry)::double precision AS lon,\n accuracy::double precision AS accuracy,\n coalesce(tracker_id, 'unknown') AS tracker\nFROM points\nWHERE timestamp >= extract(epoch from now() - interval '30 days')::integer\n AND timestamp <= extract(epoch from now())::integer\n AND lonlat IS NOT NULL\nORDER BY timestamp DESC\nLIMIT 5000;"
}
],
"fieldConfig": {
@@ -450,7 +369,8 @@
"lon": 7.5,
"zoom": 8
}
}
},
"pluginVersion": "13.0.2"
},
{
"id": 2,
@@ -476,24 +396,7 @@
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "WITH days AS (\n SELECT generate_series(\n date_trunc('day', now() - interval '30 days'),\n date_trunc('day', now()),\n interval '1 day'\n ) AS day\n)\nSELECT\n days.day AS \"time\",\n round(coalesce(sum(tracks.distance), 0)::numeric / 1000.0, 2)::double precision AS km\nFROM days\nLEFT JOIN tracks\n ON tracks.start_at >= days.day\n AND tracks.start_at < days.day + interval '1 day'\nGROUP BY days.day\nORDER BY days.day;",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "WITH days AS (\n SELECT generate_series(\n date_trunc('day', now() - interval '30 days'),\n date_trunc('day', now()),\n interval '1 day'\n ) AS day\n)\nSELECT\n days.day AS \"time\",\n round(coalesce(sum(tracks.distance), 0)::numeric / 1000.0, 2)::double precision AS km\nFROM days\nLEFT JOIN tracks\n ON tracks.start_at >= days.day\n AND tracks.start_at < days.day + interval '1 day'\nGROUP BY days.day\nORDER BY days.day;"
}
],
"fieldConfig": {
@@ -536,7 +439,8 @@
"mode": "single",
"sort": "none"
}
}
},
"pluginVersion": "13.0.2"
},
{
"id": 3,
@@ -562,24 +466,7 @@
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "WITH days AS (\n SELECT generate_series(\n date_trunc('day', now() - interval '30 days'),\n date_trunc('day', now()),\n interval '1 day'\n ) AS day\n)\nSELECT\n days.day AS \"time\",\n count(points.id)::double precision AS points\nFROM days\nLEFT JOIN points\n ON to_timestamp(points.timestamp) >= days.day\n AND to_timestamp(points.timestamp) < days.day + interval '1 day'\nGROUP BY days.day\nORDER BY days.day;",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "WITH days AS (\n SELECT generate_series(\n date_trunc('day', now() - interval '30 days'),\n date_trunc('day', now()),\n interval '1 day'\n ) AS day\n)\nSELECT\n days.day AS \"time\",\n count(points.id)::double precision AS points\nFROM days\nLEFT JOIN points\n ON to_timestamp(points.timestamp) >= days.day\n AND to_timestamp(points.timestamp) < days.day + interval '1 day'\nGROUP BY days.day\nORDER BY days.day;"
}
],
"fieldConfig": {
@@ -622,7 +509,8 @@
"mode": "single",
"sort": "none"
}
}
},
"pluginVersion": "13.0.2"
},
{
"id": 4,
@@ -648,24 +536,7 @@
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n start_at AS \"start\",\n end_at AS \"end\",\n round((distance::numeric / 1000.0), 2)::double precision AS km,\n round((duration::numeric / 60.0), 1)::double precision AS minutes\nFROM tracks\nWHERE start_at >= now() - interval '30 days'\nORDER BY start_at DESC\nLIMIT 50;",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
"rawSql": "SELECT\n start_at AS \"start\",\n end_at AS \"end\",\n round((distance::numeric / 1000.0), 2)::double precision AS km,\n round((duration::numeric / 60.0), 1)::double precision AS minutes\nFROM tracks\nWHERE start_at >= now() - interval '30 days'\nORDER BY start_at DESC\nLIMIT 50;"
}
],
"fieldConfig": {
@@ -725,7 +596,8 @@
"show": false
},
"showHeader": true
}
},
"pluginVersion": "13.0.2"
}
],
"refresh": "5m",
@@ -745,6 +617,6 @@
"timezone": "browser",
"title": "Dawarich",
"uid": "dawarich",
"version": 2,
"version": 3,
"weekStart": ""
}