tracksolid_timescale_grafan.../grafana/provisioning/dashboards-json/noc_fleet_dashboard.json

590 lines
20 KiB
JSON
Raw Permalink Normal View History

{
"title": "NOC Fleet Operations — Live",
"uid": "noc-fleet-live",
"schemaVersion": 39,
"version": 1,
"refresh": "30s",
"time": { "from": "now-1h", "to": "now" },
"timepicker": {
"refresh_intervals": ["10s", "30s", "1m", "5m"]
},
"editable": false,
"tags": ["noc", "fleet", "live"],
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"panels": [
{
"id": 1,
"type": "stat",
"title": "Total Vehicles",
"gridPos": { "x": 0, "y": 0, "w": 4, "h": 3 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"thresholds": {
"mode": "absolute",
"steps": [{ "color": "text", "value": null }]
}
},
"overrides": []
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT COUNT(*) AS \"Total Vehicles\"\nFROM tracksolid.devices WHERE enabled_flag = 1;",
"format": "table",
"refId": "A"
}
]
},
{
"id": 2,
"type": "stat",
"title": "Online Now",
"description": "GPS fix within last 5 minutes",
"gridPos": { "x": 4, "y": 0, "w": 4, "h": 3 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "red", "value": null },
{ "color": "green", "value": 1 }
]
}
},
"overrides": []
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT COUNT(*) AS \"Online\"\nFROM tracksolid.v_fleet_status\nWHERE connectivity_status = 'online';",
"format": "table",
"refId": "A"
}
]
},
{
"id": 3,
"type": "stat",
"title": "Recent (5-30 min)",
"description": "GPS fix between 5 and 30 minutes ago",
"gridPos": { "x": 8, "y": 0, "w": 4, "h": 3 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "text", "value": null },
{ "color": "yellow", "value": 1 }
]
}
},
"overrides": []
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT COUNT(*) AS \"Recent\"\nFROM tracksolid.v_fleet_status\nWHERE connectivity_status = 'recent';",
"format": "table",
"refId": "A"
}
]
},
{
"id": 4,
"type": "stat",
"title": "Offline",
"description": "GPS fix older than 30 minutes",
"gridPos": { "x": 12, "y": 0, "w": 4, "h": 3 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "red", "value": 1 }
]
}
},
"overrides": []
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT COUNT(*) AS \"Offline\"\nFROM tracksolid.v_fleet_status\nWHERE connectivity_status = 'offline';",
"format": "table",
"refId": "A"
}
]
},
{
"id": 5,
"type": "stat",
"title": "Moving Now",
"description": "Vehicles with speed > 0 and engine on",
"gridPos": { "x": 16, "y": 0, "w": 4, "h": 3 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "text", "value": null },
{ "color": "green", "value": 1 }
]
}
},
"overrides": []
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT COUNT(*) AS \"Moving\"\nFROM tracksolid.v_fleet_status\nWHERE speed > 0 AND acc_status = '1' AND connectivity_status = 'online';",
"format": "table",
"refId": "A"
}
]
},
{
"id": 6,
"type": "stat",
"title": "Avg Speed (km/h)",
"description": "Average speed of currently moving vehicles",
"gridPos": { "x": 20, "y": 0, "w": 4, "h": 3 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"unit": "velocitykmh",
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 80 },
{ "color": "red", "value": 120 }
]
}
},
"overrides": []
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT ROUND(AVG(speed)::numeric, 1) AS \"Avg Speed km/h\"\nFROM tracksolid.v_fleet_status\nWHERE speed > 0 AND acc_status = '1' AND connectivity_status = 'online';",
"format": "table",
"refId": "A"
}
]
},
{
"id": 7,
"type": "geomap",
"title": "Live Vehicle Locations",
"gridPos": { "x": 0, "y": 3, "w": 24, "h": 16 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"basemap": {
"config": { "theme": "dark" },
"name": "Basemap",
"type": "carto"
},
"controls": {
"mouseWheelZoom": true,
"showAttribution": true,
"showDebug": false,
"showScale": true,
"showZoom": true
},
"layers": [
{
"config": {
"showLegend": false,
"style": {
"color": {
"field": "vehicle_number",
"fixed": "dark-green",
"mode": "field"
},
"opacity": 1,
"rotation": {
"field": "direction",
"fixed": 0,
"max": 360,
"min": -360,
"mode": "field"
},
"size": {
"fixed": 18,
"max": 15,
"min": 2,
"mode": "fixed"
},
"symbol": {
"fixed": "img/icons/marker/arrow-up.svg",
"mode": "fixed"
},
"symbolAlign": {
"h": "center",
"v": "center"
}
}
},
"filterData": { "id": "byRefId", "options": "A" },
"location": {
"latitude": "lat",
"longitude": "lng",
"mode": "coords"
},
"name": "Vehicles",
"tooltip": true,
"type": "markers"
}
],
"tooltip": { "mode": "details" },
"view": {
"allLayers": true,
"id": "coords",
"lat": -1.5,
"lon": 36.5,
"zoom": 6
}
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic-by-name" }
},
"overrides": [
{
"matcher": { "id": "byName", "options": "lat" },
"properties": [
{ "id": "custom.hideFrom", "value": { "legend": true, "tooltip": true, "viz": false } }
]
},
{
"matcher": { "id": "byName", "options": "lng" },
"properties": [
{ "id": "custom.hideFrom", "value": { "legend": true, "tooltip": true, "viz": false } }
]
},
{
"matcher": { "id": "byName", "options": "imei" },
"properties": [
{ "id": "custom.hideFrom", "value": { "legend": true, "tooltip": true, "viz": false } }
]
},
{
"matcher": { "id": "byName", "options": "direction" },
"properties": [
{ "id": "unit", "value": "degree" },
{ "id": "displayName", "value": "Heading" }
]
},
{
"matcher": { "id": "byName", "options": "speed" },
"properties": [
{ "id": "unit", "value": "velocitykmh" },
{ "id": "displayName", "value": "Speed" }
]
},
{
"matcher": { "id": "byName", "options": "vehicle_number" },
"properties": [
{ "id": "displayName", "value": "Plate" }
]
},
{
"matcher": { "id": "byName", "options": "driver_name" },
"properties": [
{ "id": "displayName", "value": "Driver" }
]
},
{
"matcher": { "id": "byName", "options": "driver_phone" },
"properties": [
{ "id": "displayName", "value": "Phone" }
]
},
{
"matcher": { "id": "byName", "options": "vehicle_name" },
"properties": [
{ "id": "displayName", "value": "Vehicle" }
]
},
{
"matcher": { "id": "byName", "options": "connectivity_status" },
"properties": [
{ "id": "displayName", "value": "Status" },
{
"id": "mappings",
"value": [
{
"type": "value",
"options": {
"online": { "color": "green", "index": 0, "text": "Online" },
"recent": { "color": "yellow", "index": 1, "text": "Recent" },
"offline": { "color": "red", "index": 2, "text": "Offline" }
}
}
]
}
]
},
{
"matcher": { "id": "byName", "options": "acc_status" },
"properties": [
{ "id": "displayName", "value": "ACC" },
{
"id": "mappings",
"value": [
{
"type": "value",
"options": {
"1": { "text": "On", "color": "green", "index": 0 },
"0": { "text": "Off", "color": "red", "index": 1 }
}
}
]
}
]
},
{
"matcher": { "id": "byName", "options": "gps_time" },
"properties": [
{ "id": "displayName", "value": "Last Fix" }
]
},
{
"matcher": { "id": "byName", "options": "loc_desc" },
"properties": [
{ "id": "displayName", "value": "Location" }
]
}
]
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT\n d.imei,\n d.vehicle_number,\n d.vehicle_name,\n d.driver_name,\n d.driver_phone,\n d.city,\n d.device_group,\n lp.lat,\n lp.lng,\n lp.speed,\n lp.direction,\n lp.acc_status,\n lp.loc_desc,\n lp.gps_time,\n CASE\n WHEN lp.gps_time >= NOW() - INTERVAL '5 minutes' THEN 'online'\n WHEN lp.gps_time >= NOW() - INTERVAL '30 minutes' THEN 'recent'\n ELSE 'offline'\n END AS connectivity_status\nFROM tracksolid.devices d\nINNER JOIN tracksolid.live_positions lp USING (imei)\nWHERE d.enabled_flag = 1\n AND lp.lat IS NOT NULL\n AND lp.lng IS NOT NULL\nORDER BY d.vehicle_number;",
"format": "table",
"refId": "A"
}
]
},
{
"id": 8,
"type": "table",
"title": "Vehicle Status",
"gridPos": { "x": 0, "y": 19, "w": 24, "h": 10 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"cellHeight": "sm",
"footer": { "countRows": false, "fields": "", "reducer": ["sum"], "show": false },
"showHeader": true,
"sortBy": []
},
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": { "type": "auto" },
"filterable": true,
"inspect": false
}
},
"overrides": [
{
"matcher": { "id": "byName", "options": "Status" },
"properties": [
{
"id": "custom.cellOptions",
"value": { "type": "color-background", "mode": "basic" }
},
{
"id": "mappings",
"value": [
{
"type": "value",
"options": {
"Online": { "color": "green", "index": 0 },
"Recent": { "color": "yellow", "index": 1 },
"Offline": { "color": "red", "index": 2 }
}
}
]
}
]
},
{
"matcher": { "id": "byName", "options": "Speed (km/h)" },
"properties": [
{
"id": "custom.cellOptions",
"value": { "type": "color-text" }
},
{
"id": "color",
"value": { "mode": "thresholds" }
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 80 },
{ "color": "red", "value": 120 }
]
}
}
]
},
{
"matcher": { "id": "byName", "options": "Last Fix" },
"properties": [
{ "id": "unit", "value": "dateTimeAsLocal" }
]
},
{
"matcher": { "id": "byName", "options": "Min Since Fix" },
"properties": [
{ "id": "custom.width", "value": 110 },
{ "id": "displayName", "value": "Min Ago" }
]
},
{
"matcher": { "id": "byName", "options": "Driver Phone" },
"properties": [
{ "id": "custom.width", "value": 130 }
]
},
{
"matcher": { "id": "byName", "options": "Plate" },
"properties": [
{ "id": "custom.width", "value": 110 }
]
}
]
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT\n d.vehicle_number AS \"Plate\",\n d.vehicle_name AS \"Vehicle\",\n d.driver_name AS \"Driver\",\n d.driver_phone AS \"Driver Phone\",\n d.city AS \"City\",\n ROUND(lp.speed::numeric, 0) AS \"Speed (km/h)\",\n lp.loc_desc AS \"Last Location\",\n lp.gps_time AS \"Last Fix\",\n CASE\n WHEN lp.gps_time >= NOW() - INTERVAL '5 minutes' THEN 'Online'\n WHEN lp.gps_time >= NOW() - INTERVAL '30 minutes' THEN 'Recent'\n ELSE 'Offline'\n END AS \"Status\",\n EXTRACT(EPOCH FROM (NOW() - lp.gps_time))::int / 60 AS \"Min Since Fix\"\nFROM tracksolid.devices d\nLEFT JOIN tracksolid.live_positions lp USING (imei)\nWHERE d.enabled_flag = 1\nORDER BY\n CASE\n WHEN lp.gps_time >= NOW() - INTERVAL '5 minutes' THEN 0\n WHEN lp.gps_time >= NOW() - INTERVAL '30 minutes' THEN 1\n ELSE 2\n END,\n d.vehicle_number;",
"format": "table",
"refId": "A"
}
]
},
{
"id": 9,
"type": "table",
"title": "Ingestion Health",
"collapsed": true,
"gridPos": { "x": 0, "y": 29, "w": 24, "h": 8 },
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"options": {
"cellHeight": "sm",
"footer": { "countRows": false, "fields": "", "reducer": ["sum"], "show": false },
"showHeader": true
},
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": { "type": "auto" },
"filterable": false,
"inspect": false
}
},
"overrides": [
{
"matcher": { "id": "byName", "options": "Result" },
"properties": [
{
"id": "custom.cellOptions",
"value": { "type": "color-background", "mode": "basic" }
},
{
"id": "mappings",
"value": [
{
"type": "value",
"options": {
"OK": { "color": "green", "index": 0 },
"FAIL": { "color": "red", "index": 1 }
}
}
]
}
]
}
]
},
"targets": [
{
"datasource": { "type": "postgres", "uid": "tracksolid_pg" },
"rawSql": "SELECT\n endpoint AS \"Endpoint\",\n TO_CHAR(run_at, 'HH24:MI DD-Mon') AS \"Last Run\",\n CASE WHEN success THEN 'OK' ELSE 'FAIL' END AS \"Result\",\n error_message AS \"Error\",\n seconds_ago AS \"Lag (s)\"\nFROM tracksolid.v_ingestion_health\nORDER BY endpoint;",
"format": "table",
"refId": "A"
}
]
}
]
}