From 45ff8286cf739ab4b677ce98eb05f42cfb20e074 Mon Sep 17 00:00:00 2001 From: Micha Date: Mon, 22 Jun 2026 20:20:07 +0200 Subject: [PATCH] Use table-format Dawarich Grafana panels --- apps/dawarich/grafana/dashboard-dawarich.json | 589 ++++++++---------- monitoring/grafana/dashboards/dawarich.json | 589 ++++++++---------- 2 files changed, 544 insertions(+), 634 deletions(-) diff --git a/apps/dawarich/grafana/dashboard-dawarich.json b/apps/dawarich/grafana/dashboard-dawarich.json index c4d477a..a23d17c 100644 --- a/apps/dawarich/grafana/dashboard-dawarich.json +++ b/apps/dawarich/grafana/dashboard-dawarich.json @@ -30,11 +30,12 @@ "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 4, - "w": 6, "x": 0, - "y": 0 + "y": 0, + "w": 6, + "h": 4 }, "targets": [ { @@ -44,9 +45,9 @@ "uid": "dawarich-postgres" }, "editorMode": "code", - "format": "time_series", + "format": "table", "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;" + "rawSql": "SELECT 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": { @@ -67,7 +68,7 @@ }, "options": { "colorMode": "value", - "graphMode": "area", + "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { @@ -79,8 +80,7 @@ }, "textMode": "auto", "wideLayout": true - }, - "pluginVersion": "13.0.2" + } }, { "id": 11, @@ -90,11 +90,12 @@ "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 4, - "w": 6, "x": 6, - "y": 0 + "y": 0, + "w": 6, + "h": 4 }, "targets": [ { @@ -104,9 +105,9 @@ "uid": "dawarich-postgres" }, "editorMode": "code", - "format": "time_series", + "format": "table", "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';" + "rawSql": "SELECT round(coalesce(sum(distance),0)::numeric / 1000.0, 2)::double precision AS km\nFROM tracks\nWHERE start_at >= now() - interval '30 days';" } ], "fieldConfig": { @@ -127,7 +128,7 @@ }, "options": { "colorMode": "value", - "graphMode": "area", + "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { @@ -139,8 +140,7 @@ }, "textMode": "auto", "wideLayout": true - }, - "pluginVersion": "13.0.2" + } }, { "id": 12, @@ -150,135 +150,12 @@ "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 4, - "w": 6, "x": 12, - "y": 0 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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';" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "tracks", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "13.0.2" - }, - { - "id": 13, - "type": "stat", - "title": "Anomalies Last 30 Days", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 4, + "y": 0, "w": 6, - "x": 18, - "y": 0 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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;" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "orange", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "anomalies", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "13.0.2" - }, - { - "id": 1, - "type": "geomap", - "title": "Location Points", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 12, - "w": 14, - "x": 0, - "y": 4 + "h": 4 }, "targets": [ { @@ -290,7 +167,127 @@ "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;" + "rawSql": "SELECT count(*)::double precision AS tracks\nFROM tracks\nWHERE start_at >= now() - interval '30 days';" + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "tracks", + "values": false + }, + "textMode": "auto", + "wideLayout": true + } + }, + { + "id": 13, + "type": "stat", + "title": "Anomalies Last 30 Days", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "pluginVersion": "13.0.2", + "gridPos": { + "x": 18, + "y": 0, + "w": 6, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT 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": { + "defaults": { + "unit": "short", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "anomalies", + "values": false + }, + "textMode": "auto", + "wideLayout": true + } + }, + { + "id": 1, + "type": "geomap", + "title": "Location Points", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "pluginVersion": "13.0.2", + "gridPos": { + "x": 0, + "y": 4, + "w": 14, + "h": 12 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\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 to_timestamp(timestamp) AS seen_at\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": { @@ -369,162 +366,22 @@ "lon": 7.5, "zoom": 8 } - }, - "pluginVersion": "13.0.2" + } }, { "id": 2, - "type": "timeseries", + "type": "table", "title": "Kilometers per Day", "datasource": { "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 6, - "w": 10, "x": 14, - "y": 4 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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;" - } - ], - "fieldConfig": { - "defaults": { - "unit": "km", - "color": { - "mode": "palette-classic" - }, - "custom": { - "drawStyle": "bars", - "fillOpacity": 70, - "lineWidth": 1, - "showPoints": "never", - "axisPlacement": "auto", - "barAlignment": 0 - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "options": { - "legend": { - "calcs": [ - "sum" - ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "13.0.2" - }, - { - "id": 3, - "type": "timeseries", - "title": "Points per Day", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 6, + "y": 4, "w": 10, - "x": 14, - "y": 10 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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;" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "color": { - "mode": "palette-classic" - }, - "custom": { - "drawStyle": "bars", - "fillOpacity": 70, - "lineWidth": 1, - "showPoints": "never", - "axisPlacement": "auto", - "barAlignment": 0 - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "options": { - "legend": { - "calcs": [ - "sum" - ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "13.0.2" - }, - { - "id": 4, - "type": "table", - "title": "Recent Tracks", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 16 + "h": 6 }, "targets": [ { @@ -536,7 +393,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;" + "rawSql": "SELECT\n date_trunc('day', start_at)::date AS day,\n round(coalesce(sum(distance),0)::numeric / 1000.0, 2)::double precision AS km\nFROM tracks\nWHERE start_at >= now() - interval '30 days'\nGROUP BY 1\nORDER BY 1 DESC;" } ], "fieldConfig": { @@ -558,32 +415,7 @@ ] } }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "km" - }, - "properties": [ - { - "id": "unit", - "value": "km" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "minutes" - }, - "properties": [ - { - "id": "unit", - "value": "m" - } - ] - } - ] + "overrides": [] }, "options": { "cellHeight": "sm", @@ -596,8 +428,131 @@ "show": false }, "showHeader": true + } + }, + { + "id": 3, + "type": "table", + "title": "Points per Day", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" }, - "pluginVersion": "13.0.2" + "pluginVersion": "13.0.2", + "gridPos": { + "x": 14, + "y": 10, + "w": 10, + "h": 6 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n date_trunc('day', to_timestamp(timestamp))::date AS day,\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\nGROUP BY 1\nORDER BY 1 DESC;" + } + ], + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + } + }, + { + "id": 4, + "type": "table", + "title": "Recent Tracks", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "pluginVersion": "13.0.2", + "gridPos": { + "x": 0, + "y": 16, + "w": 24, + "h": 7 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "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;" + } + ], + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + } } ], "refresh": "5m", @@ -617,6 +572,6 @@ "timezone": "browser", "title": "Dawarich", "uid": "dawarich", - "version": 3, + "version": 5, "weekStart": "" } diff --git a/monitoring/grafana/dashboards/dawarich.json b/monitoring/grafana/dashboards/dawarich.json index c4d477a..a23d17c 100644 --- a/monitoring/grafana/dashboards/dawarich.json +++ b/monitoring/grafana/dashboards/dawarich.json @@ -30,11 +30,12 @@ "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 4, - "w": 6, "x": 0, - "y": 0 + "y": 0, + "w": 6, + "h": 4 }, "targets": [ { @@ -44,9 +45,9 @@ "uid": "dawarich-postgres" }, "editorMode": "code", - "format": "time_series", + "format": "table", "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;" + "rawSql": "SELECT 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": { @@ -67,7 +68,7 @@ }, "options": { "colorMode": "value", - "graphMode": "area", + "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { @@ -79,8 +80,7 @@ }, "textMode": "auto", "wideLayout": true - }, - "pluginVersion": "13.0.2" + } }, { "id": 11, @@ -90,11 +90,12 @@ "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 4, - "w": 6, "x": 6, - "y": 0 + "y": 0, + "w": 6, + "h": 4 }, "targets": [ { @@ -104,9 +105,9 @@ "uid": "dawarich-postgres" }, "editorMode": "code", - "format": "time_series", + "format": "table", "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';" + "rawSql": "SELECT round(coalesce(sum(distance),0)::numeric / 1000.0, 2)::double precision AS km\nFROM tracks\nWHERE start_at >= now() - interval '30 days';" } ], "fieldConfig": { @@ -127,7 +128,7 @@ }, "options": { "colorMode": "value", - "graphMode": "area", + "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { @@ -139,8 +140,7 @@ }, "textMode": "auto", "wideLayout": true - }, - "pluginVersion": "13.0.2" + } }, { "id": 12, @@ -150,135 +150,12 @@ "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 4, - "w": 6, "x": 12, - "y": 0 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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';" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "tracks", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "13.0.2" - }, - { - "id": 13, - "type": "stat", - "title": "Anomalies Last 30 Days", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 4, + "y": 0, "w": 6, - "x": 18, - "y": 0 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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;" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "orange", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "anomalies", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "13.0.2" - }, - { - "id": 1, - "type": "geomap", - "title": "Location Points", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 12, - "w": 14, - "x": 0, - "y": 4 + "h": 4 }, "targets": [ { @@ -290,7 +167,127 @@ "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;" + "rawSql": "SELECT count(*)::double precision AS tracks\nFROM tracks\nWHERE start_at >= now() - interval '30 days';" + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "tracks", + "values": false + }, + "textMode": "auto", + "wideLayout": true + } + }, + { + "id": 13, + "type": "stat", + "title": "Anomalies Last 30 Days", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "pluginVersion": "13.0.2", + "gridPos": { + "x": 18, + "y": 0, + "w": 6, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT 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": { + "defaults": { + "unit": "short", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "anomalies", + "values": false + }, + "textMode": "auto", + "wideLayout": true + } + }, + { + "id": 1, + "type": "geomap", + "title": "Location Points", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "pluginVersion": "13.0.2", + "gridPos": { + "x": 0, + "y": 4, + "w": 14, + "h": 12 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\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 to_timestamp(timestamp) AS seen_at\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": { @@ -369,162 +366,22 @@ "lon": 7.5, "zoom": 8 } - }, - "pluginVersion": "13.0.2" + } }, { "id": 2, - "type": "timeseries", + "type": "table", "title": "Kilometers per Day", "datasource": { "type": "postgres", "uid": "dawarich-postgres" }, + "pluginVersion": "13.0.2", "gridPos": { - "h": 6, - "w": 10, "x": 14, - "y": 4 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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;" - } - ], - "fieldConfig": { - "defaults": { - "unit": "km", - "color": { - "mode": "palette-classic" - }, - "custom": { - "drawStyle": "bars", - "fillOpacity": 70, - "lineWidth": 1, - "showPoints": "never", - "axisPlacement": "auto", - "barAlignment": 0 - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "options": { - "legend": { - "calcs": [ - "sum" - ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "13.0.2" - }, - { - "id": 3, - "type": "timeseries", - "title": "Points per Day", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 6, + "y": 4, "w": 10, - "x": 14, - "y": 10 - }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "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;" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "color": { - "mode": "palette-classic" - }, - "custom": { - "drawStyle": "bars", - "fillOpacity": 70, - "lineWidth": 1, - "showPoints": "never", - "axisPlacement": "auto", - "barAlignment": 0 - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "options": { - "legend": { - "calcs": [ - "sum" - ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "13.0.2" - }, - { - "id": 4, - "type": "table", - "title": "Recent Tracks", - "datasource": { - "type": "postgres", - "uid": "dawarich-postgres" - }, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 16 + "h": 6 }, "targets": [ { @@ -536,7 +393,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;" + "rawSql": "SELECT\n date_trunc('day', start_at)::date AS day,\n round(coalesce(sum(distance),0)::numeric / 1000.0, 2)::double precision AS km\nFROM tracks\nWHERE start_at >= now() - interval '30 days'\nGROUP BY 1\nORDER BY 1 DESC;" } ], "fieldConfig": { @@ -558,32 +415,7 @@ ] } }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "km" - }, - "properties": [ - { - "id": "unit", - "value": "km" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "minutes" - }, - "properties": [ - { - "id": "unit", - "value": "m" - } - ] - } - ] + "overrides": [] }, "options": { "cellHeight": "sm", @@ -596,8 +428,131 @@ "show": false }, "showHeader": true + } + }, + { + "id": 3, + "type": "table", + "title": "Points per Day", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" }, - "pluginVersion": "13.0.2" + "pluginVersion": "13.0.2", + "gridPos": { + "x": 14, + "y": 10, + "w": 10, + "h": 6 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n date_trunc('day', to_timestamp(timestamp))::date AS day,\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\nGROUP BY 1\nORDER BY 1 DESC;" + } + ], + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + } + }, + { + "id": 4, + "type": "table", + "title": "Recent Tracks", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "pluginVersion": "13.0.2", + "gridPos": { + "x": 0, + "y": 16, + "w": 24, + "h": 7 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "postgres", + "uid": "dawarich-postgres" + }, + "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;" + } + ], + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + } } ], "refresh": "5m", @@ -617,6 +572,6 @@ "timezone": "browser", "title": "Dawarich", "uid": "dawarich", - "version": 3, + "version": 5, "weekStart": "" }