Files
archived-hipudding-teslamate/grafana/dashboards/updates.json
Matthias Wirtz bdf4e4e3f0 perf: improvement and deprecated syntax removal (#4304)
* always use ideal_battery_range_km in conditions (to make use of index)

* remove deprecated var syntax
2024-10-27 08:31:14 +01:00

805 lines
21 KiB
JSON

{
"__elements": {},
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "11.1.0"
},
{
"type": "datasource",
"id": "grafana-postgresql-datasource",
"name": "PostgreSQL",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
}
],
"annotations": {
"list": [
{
"$$hashKey": "object:15",
"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,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"links": [
{
"icon": "dashboard",
"tags": [],
"title": "TeslaMate",
"tooltip": "",
"type": "link",
"url": "${base_url:raw}"
},
{
"asDropdown": true,
"icon": "external link",
"tags": [
"tesla"
],
"title": "Dashboards",
"type": "dashboards"
}
],
"liveNow": false,
"panels": [
{
"datasource": "TeslaMate",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 4,
"panels": [],
"repeat": "car_id",
"title": "$car_id",
"type": "row"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "#c7d0d9",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 8,
"x": 0,
"y": 1
},
"id": 8,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"count"
],
"fields": "",
"values": true
},
"showPercentChange": false,
"textMode": "value",
"wideLayout": true
},
"pluginVersion": "11.1.0",
"targets": [
{
"format": "table",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT count(*)\nFROM updates\nWHERE $__timeFilter(start_date) AND car_id = $car_id",
"refId": "A",
"select": [
[
{
"params": [
"start_km"
],
"type": "column"
}
]
],
"table": "drives",
"timeColumn": "start_date",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
],
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
}
}
],
"title": "Updates",
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"decimals": 1,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "#c7d0d9",
"value": null
}
]
},
"unit": "dtdurations"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 16,
"x": 8,
"y": 1
},
"id": 6,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": true
},
"showPercentChange": false,
"textMode": "value",
"wideLayout": true
},
"pluginVersion": "11.1.0",
"targets": [
{
"format": "table",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT percentile_disc(0.5) WITHIN GROUP (ORDER BY since_last_update) FROM (\n\tSELECT extract(EPOCH FROM start_date - lag(start_date) OVER (ORDER BY start_date)) AS since_last_update\n\tFROM updates\n\tWHERE $__timeFilter(start_date) AND car_id = $car_id\n) d;",
"refId": "A",
"select": [
[
{
"params": [
"start_km"
],
"type": "column"
}
]
],
"table": "drives",
"timeColumn": "start_date",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
],
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
}
}
],
"title": "Median time between updates",
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"filterable": false,
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "time"
},
"properties": [
{
"id": "custom.width",
"value": 200
},
{
"id": "displayName",
"value": "Date"
},
{
"id": "unit",
"value": "dateTimeAsLocal"
}
]
},
{
"matcher": {
"id": "byName",
"options": "update_duration"
},
"properties": [
{
"id": "custom.width",
"value": 100
},
{
"id": "displayName",
"value": "Duration"
},
{
"id": "unit",
"value": "dtdurations"
}
]
},
{
"matcher": {
"id": "byName",
"options": "since_last_update"
},
"properties": [
{
"id": "custom.width",
"value": 160
},
{
"id": "displayName",
"value": "Since Previous Update"
}
]
},
{
"matcher": {
"id": "byName",
"options": "version"
},
"properties": [
{
"id": "displayName",
"value": "Installed Version"
},
{
"id": "custom.align",
"value": "right"
},
{
"id": "decimals",
"value": 2
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "${__data.fields[version]} release notes",
"url": "https://www.notateslaapp.com/software-updates/version/${__data.fields[version]}/release-notes"
}
]
},
{
"id": "unit",
"value": "string"
}
]
},
{
"matcher": {
"id": "byName",
"options": "chg_ct"
},
"properties": [
{
"id": "custom.width",
"value": 100
},
{
"id": "displayName",
"value": "# of Charges"
}
]
},
{
"matcher": {
"id": "byName",
"options": "avg_ideal_range_km"
},
"properties": [
{
"id": "custom.width",
"value": 150
},
{
"id": "decimals",
"value": 1
},
{
"id": "unit",
"value": "lengthkm"
},
{
"id": "displayName",
"value": "Avg ideal range"
}
]
},
{
"matcher": {
"id": "byName",
"options": "avg_rated_range_km"
},
"properties": [
{
"id": "custom.width",
"value": 150
},
{
"id": "decimals",
"value": 1
},
{
"id": "unit",
"value": "lengthkm"
},
{
"id": "displayName",
"value": "Avg rated range"
}
]
},
{
"matcher": {
"id": "byName",
"options": "avg_ideal_range_mi"
},
"properties": [
{
"id": "custom.width",
"value": 150
},
{
"id": "decimals",
"value": 1
},
{
"id": "unit",
"value": "lengthmi"
},
{
"id": "displayName",
"value": "Avg ideal range"
}
]
},
{
"matcher": {
"id": "byName",
"options": "avg_rated_range_mi"
},
"properties": [
{
"id": "custom.width",
"value": 150
},
{
"id": "decimals",
"value": 1
},
{
"id": "unit",
"value": "lengthmi"
},
{
"id": "displayName",
"value": "Avg rated range"
}
]
}
]
},
"gridPos": {
"h": 28,
"w": 24,
"x": 0,
"y": 4
},
"id": 2,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Date"
}
]
},
"pluginVersion": "11.1.0",
"scroll": true,
"showHeader": true,
"sort": {
"col": 0,
"desc": true
},
"styles": [
{
"$$hashKey": "object:68",
"alias": "Date",
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "start_date",
"type": "date"
},
{
"$$hashKey": "object:69",
"alias": "End Date",
"align": "auto",
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 2,
"mappingType": 1,
"pattern": "end_date",
"thresholds": [],
"type": "hidden",
"unit": "short"
},
{
"$$hashKey": "object:70",
"alias": "Installed Version",
"align": "auto",
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 2,
"link": true,
"linkTargetBlank": true,
"linkTooltip": "${__cell} release info",
"linkUrl": "https://www.notateslaapp.com/software-updates/version/${__cell}/release-notes",
"mappingType": 1,
"pattern": "version",
"thresholds": [],
"type": "string",
"unit": "short"
},
{
"$$hashKey": "object:202",
"alias": "Duration",
"align": "auto",
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 0,
"mappingType": 1,
"pattern": "update_duration",
"thresholds": [],
"type": "number",
"unit": "dtdurations"
},
{
"$$hashKey": "object:392",
"alias": "Since Previous Update",
"align": "auto",
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 0,
"mappingType": 1,
"pattern": "since_last_update",
"thresholds": [],
"type": "number",
"unit": "dtdurations"
},
{
"$$hashKey": "object:71",
"alias": "# of Charges",
"align": "auto",
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"decimals": 0,
"pattern": "chg_ct",
"thresholds": [],
"type": "number",
"unit": "short"
}
],
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
"format": "table",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "with u as (\r\n select *, coalesce(lag(start_date) over(order by start_date desc), now()) as next_start_date \r\n from updates\r\n where car_id = $car_id and $__timeFilter(start_date)\r\n),\r\nrng as (\r\n SELECT\r\n\t date_trunc('hour', date) AS date,\r\n\t (sum(${preferred_range}_battery_range_km)/ nullif(sum(usable_battery_level),0) * 100 ) AS \"battery_rng\",\r\n\t sum(case when action = 'Charge' then 1 else 0 end) as chg_ct\r\n FROM (\r\n select coalesce(usable_battery_level, battery_level) as usable_battery_level, start_date as date, start_rated_range_km as rated_battery_range_km, start_ideal_range_km as ideal_battery_range_km, 'Drive' as action\r\n from drives d\r\n inner join positions p on d.start_position_id = p.id \r\n where d.car_id = $car_id and $__timeFilter(start_date)\r\n union all\r\n select end_battery_level as usable_battery_level, end_date, end_rated_range_km as rated_battery_range_km, end_ideal_range_km as ideal_battery_range_km, 'Charge' as action\r\n from charging_processes p\r\n where $__timeFilter(end_date) and p.car_id = $car_id\r\n ) as data\r\n GROUP BY 1\r\n)\r\n\r\nselect\t\r\n u.start_date as time,\r\n\textract(EPOCH FROM u.end_date - u.start_date) AS update_duration,\r\n\tage(date(u.start_date), date(lag(u.start_date) OVER (ORDER BY u.start_date))) AS since_last_update,\r\n\tsplit_part(u.version, ' ', 1) as version,\r\n\tsum(r.chg_ct) as chg_ct,\r\n\tconvert_km(avg(r.battery_rng), '$length_unit')::numeric(6,2) AS avg_${preferred_range}_range_${length_unit}\r\nfrom u u\r\nleft join rng r\r\n\tON r.date between u.start_date and u.next_start_date\r\ngroup by u.car_id,\r\n\tu.start_date,\r\n\tu.end_date,\r\n\tnext_start_date,\r\n\tsplit_part(u.version, ' ', 1)",
"refId": "A",
"select": [
[
{
"params": [
"efficiency"
],
"type": "column"
}
]
],
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "cars",
"timeColumn": "inserted_at",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"title": "Updates",
"type": "table"
}
],
"schemaVersion": 39,
"tags": [
"tesla"
],
"templating": {
"list": [
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, RIGHT(vin, 6)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;",
"hide": 2,
"includeAll": true,
"label": "Car",
"multi": false,
"name": "car_id",
"options": [],
"query": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, RIGHT(vin, 6)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select preferred_range from settings limit 1;",
"hide": 2,
"includeAll": false,
"multi": false,
"name": "preferred_range",
"options": [],
"query": "select preferred_range from settings limit 1;",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_length from settings limit 1;",
"hide": 2,
"includeAll": false,
"multi": false,
"name": "length_unit",
"options": [],
"query": "select unit_of_length from settings limit 1;",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select base_url from settings limit 1;",
"hide": 2,
"includeAll": false,
"label": "",
"multi": false,
"name": "base_url",
"options": [],
"query": "select base_url from settings limit 1;",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-10y",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "Updates",
"uid": "IiC07mgWz",
"version": 2,
"weekStart": ""
}