fix: properly escape rawSql newlines in sportmetrics dashboard

This commit is contained in:
2026-03-25 00:09:16 +01:00
parent e802ca044a
commit d83536a29b
@@ -78,17 +78,27 @@ data:
"panels": [
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 10,
"panels": [],
"title": "Cluster",
"type": "row"
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
@@ -100,17 +110,28 @@ data:
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": { "type": "linear" },
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"showValues": false,
"spanNulls": false,
"stacking": { "group": "A", "mode": "normal" },
"thresholdsStyle": { "mode": "off" }
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"max": 1,
@@ -118,30 +139,48 @@ data:
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": 0 },
{ "color": "red", "value": 80 }
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": { "h": 7, "w": 12, "x": 0, "y": 1 },
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 1
},
"id": 11,
"options": {
"legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true },
"tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "12.4.1",
"targets": [
{
"datasource": { "type": "prometheus", "uid": "$datasource" },
"expr": "(
(1 - sum without (mode) (rate(node_cpu_seconds_total{job=\"node-exporter\", mode=~\"idle|iowait|steal\", instance=\"$instance\", cluster=~\"$cluster\"}[$__rate_interval])))
/ ignoring(cpu) group_left
count without (cpu, mode) (node_cpu_seconds_total{job=\"node-exporter\", mode=\"idle\", instance=\"$instance\", cluster=~\"$cluster\"})
)
",
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "(\n (1 - sum without (mode) (rate(node_cpu_seconds_total{job=\"node-exporter\", mode=~\"idle|iowait|steal\", instance=\"$instance\", cluster=~\"$cluster\"}[$__rate_interval])))\n/ ignoring(cpu) group_left\n count without (cpu, mode) (node_cpu_seconds_total{job=\"node-exporter\", mode=\"idle\", instance=\"$instance\", cluster=~\"$cluster\"})\n)\n",
"intervalFactor": 5,
"legendFormat": "{{cpu}}",
"refId": "A"
@@ -151,10 +190,15 @@ data:
"type": "timeseries"
},
{
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
@@ -166,68 +210,102 @@ data:
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": { "type": "linear" },
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"showValues": false,
"spanNulls": false,
"stacking": { "group": "A", "mode": "normal" },
"thresholdsStyle": { "mode": "off" }
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": 0 },
{ "color": "red", "value": 80 }
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": { "h": 7, "w": 12, "x": 12, "y": 1 },
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 1
},
"id": 12,
"options": {
"legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true },
"tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
}
},
"pluginVersion": "12.4.1",
"targets": [
{
"datasource": { "type": "prometheus", "uid": "$datasource" },
"expr": "(
node_memory_MemTotal_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}
-
node_memory_MemFree_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}
-
node_memory_Buffers_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}
-
node_memory_Cached_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}
)
",
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "(\n node_memory_MemTotal_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}\n-\n node_memory_MemFree_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}\n-\n node_memory_Buffers_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}\n-\n node_memory_Cached_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}\n)\n",
"legendFormat": "memory used",
"refId": "A"
},
{
"datasource": { "type": "prometheus", "uid": "$datasource" },
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "node_memory_Buffers_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}",
"legendFormat": "memory buffers",
"refId": "B"
},
{
"datasource": { "type": "prometheus", "uid": "$datasource" },
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "node_memory_Cached_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}",
"legendFormat": "memory cached",
"refId": "C"
},
{
"datasource": { "type": "prometheus", "uid": "$datasource" },
"datasource": {
"type": "prometheus",
"uid": "$datasource"
},
"expr": "node_memory_MemFree_bytes{job=\"node-exporter\", instance=\"$instance\", cluster=~\"$cluster\"}",
"legendFormat": "memory free",
"refId": "D"
@@ -238,192 +316,478 @@ data:
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 8 },
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 8
},
"id": 5,
"panels": [],
"title": "Fitness",
"type": "row"
},
{
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text",
"axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6,
"drawStyle": "line", "fillOpacity": 25, "gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5,
"scaleDistribution": { "type": "linear" }, "showPoints": "auto", "showValues": false,
"spanNulls": false, "stacking": { "group": "A", "mode": "none" },
"thresholdsStyle": { "mode": "off" }
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 25,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] }
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": { "h": 7, "w": 12, "x": 0, "y": 9 },
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 9
},
"id": 2,
"options": {
"legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true },
"tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.4.1",
"targets": [
{
"dataset": "garmin",
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"editorMode": "code", "format": "table", "rawQuery": true,
"rawSql": "SELECT
start_time AS time,
(duration_seconds / 60) / (distance_meters / 1000) AS \"Pace (min/km)\"
FROM activities
WHERE type = 'running'
AND distance_meters > 0
ORDER BY start_time",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n start_time AS time,\n (duration_seconds / 60) / (distance_meters / 1000) AS \"Pace (min/km)\"\nFROM activities\nWHERE type = 'running'\n AND distance_meters > 0\nORDER BY start_time",
"refId": "A",
"sql": { "columns": [{ "parameters": [], "type": "function" }], "groupBy": [{ "property": { "type": "string" }, "type": "groupBy" }], "limit": 50 }
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "pace",
"type": "timeseries"
},
{
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text",
"axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6,
"drawStyle": "line", "fillOpacity": 0, "gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5,
"scaleDistribution": { "type": "linear" }, "showPoints": "auto", "showValues": false,
"spanNulls": false, "stacking": { "group": "A", "mode": "none" },
"thresholdsStyle": { "mode": "off" }
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] }
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": { "h": 7, "w": 12, "x": 12, "y": 9 },
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 9
},
"id": 4,
"options": {
"legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true },
"tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.4.1",
"targets": [
{
"dataset": "garmin",
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"editorMode": "code", "format": "table", "rawQuery": true,
"rawSql": "SELECT
start_time AS time,
max_hr AS \"Max HR\"
FROM activities
WHERE type = 'running'
AND max_hr IS NOT NULL
ORDER BY start_time",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n start_time AS time,\n max_hr AS \"Max HR\"\nFROM activities\nWHERE type = 'running'\n AND max_hr IS NOT NULL\nORDER BY start_time",
"refId": "A",
"sql": { "columns": [{ "parameters": [], "type": "function" }], "groupBy": [{ "property": { "type": "string" }, "type": "groupBy" }], "limit": 50 }
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "max hr",
"type": "timeseries"
},
{
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": true, "axisCenteredZero": false, "axisColorMode": "text",
"axisGridShow": false, "axisLabel": "", "axisPlacement": "auto",
"barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "bars",
"fillOpacity": 100, "gradientMode": "hue",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5,
"scaleDistribution": { "type": "linear" }, "showPoints": "auto", "showValues": false,
"spanNulls": false, "stacking": { "group": "A", "mode": "none" },
"thresholdsStyle": { "mode": "off" }
"axisBorderShow": true,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisGridShow": false,
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "bars",
"fillOpacity": 100,
"gradientMode": "hue",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] }
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": { "h": 7, "w": 12, "x": 0, "y": 16 },
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 16
},
"id": 1,
"options": {
"legend": { "calcs": [], "displayMode": "list", "placement": "right", "showLegend": true },
"tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.4.1",
"targets": [
{
"dataset": "garmin",
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"editorMode": "code", "format": "table", "rawQuery": true,
"rawSql": "SELECT
start_time AS time,
distance_meters / 1000 AS \"Distanz (km)\"
FROM activities
WHERE type = 'running'
ORDER BY start_time",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n start_time AS time,\n distance_meters / 1000 AS \"Distanz (km)\"\nFROM activities\nWHERE type = 'running'\nORDER BY start_time",
"refId": "A",
"sql": { "columns": [{ "parameters": [], "type": "function" }], "groupBy": [{ "property": { "type": "string" }, "type": "groupBy" }], "limit": 50 }
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "distance",
"type": "timeseries"
},
{
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": true, "axisCenteredZero": false, "axisColorMode": "text",
"axisGridShow": false, "axisLabel": "", "axisPlacement": "auto",
"barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "bars",
"fillOpacity": 100, "gradientMode": "hue",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5,
"scaleDistribution": { "type": "linear" }, "showPoints": "auto", "showValues": false,
"spanNulls": false, "stacking": { "group": "A", "mode": "none" },
"thresholdsStyle": { "mode": "off" }
"axisBorderShow": true,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisGridShow": false,
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "bars",
"fillOpacity": 100,
"gradientMode": "hue",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] }
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": { "h": 7, "w": 12, "x": 12, "y": 16 },
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 16
},
"id": 3,
"options": {
"legend": { "calcs": [], "displayMode": "list", "placement": "right", "showLegend": true },
"tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "right",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "12.4.1",
"targets": [
{
"dataset": "garmin",
"datasource": { "type": "grafana-postgresql-datasource", "uid": "bfgdydx75ju2of" },
"editorMode": "code", "format": "table", "rawQuery": true,
"rawSql": "SELECT
start_time AS time,
vo2max
FROM activities
WHERE type = 'running'
AND vo2max IS NOT NULL
ORDER BY start_time",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "bfgdydx75ju2of"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n start_time AS time,\n vo2max\nFROM activities\nWHERE type = 'running'\n AND vo2max IS NOT NULL\nORDER BY start_time",
"refId": "A",
"sql": { "columns": [{ "parameters": [], "type": "function" }], "groupBy": [{ "property": { "type": "string" }, "type": "groupBy" }], "limit": 50 }
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "vo2max",
@@ -434,7 +798,10 @@ data:
"refresh": "30s",
"schemaVersion": 42,
"tags": [],
"time": { "from": "now-6h", "to": "now" },
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "sportmetrics",