fix(monitoring): make Grafana dashboards importable on older Grafana (#3972)

The three bundled dashboards used save-model shapes that only exist in
Grafana >= 8.3: an object datasource ref ({"type", "uid"}) and the
Prometheus variable-editor query object ({"query", "refId"}). Grafana's
DashboardMigrator only ever migrates up, so on an older instance
(reproduced on 7.5.17) both objects are handed to templateSrv.replace(),
which calls target.replace() and throws "e.replace is not a function".
The templating error aborts variable init and leaves every panel empty.

Switch to the string forms, which modern Grafana still accepts and
migrates at runtime:

- "datasource": "$datasource" on every panel plus a datasource template
  variable ("query": "prometheus", "current": {}), so any Prometheus
  datasource is auto-selected. This also drops the hardcoded
  "uid": "prometheus", which only exists in the grafana/otel-lgtm image
  used by scripts/dev/monitoring and made the dashboards unusable
  elsewhere ("Datasource prometheus was not found").
- the tenant variable keeps the legacy string query label_values(...).

${DS_PROMETHEUS} + __inputs was rejected because file provisioning does
not substitute inputs, and "datasource": null because otel-lgtm marks no
datasource as isDefault.

Fixes #3968
This commit is contained in:
Nick Old
2026-09-01 16:50:15 +08:00
committed by GitHub
parent 4fa110dd59
commit 7083fd7909
3 changed files with 85 additions and 172 deletions
@@ -17,10 +17,7 @@
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -62,10 +59,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -107,10 +101,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -152,10 +143,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -199,10 +187,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -244,10 +229,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -322,10 +304,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -423,10 +402,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -527,10 +503,7 @@
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -572,10 +545,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -618,10 +588,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -664,10 +631,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -709,10 +673,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -830,10 +791,7 @@
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -875,10 +833,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -920,10 +875,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -965,10 +917,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -1010,10 +959,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -1088,10 +1034,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -1180,10 +1123,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -1277,6 +1217,20 @@
"tags": ["hindsight", "api", "service"],
"templating": {
"list": [
{
"current": {},
"hide": 0,
"includeAll": false,
"label": "Data source",
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
},
{
"allValue": ".*",
"current": {
@@ -1284,10 +1238,7 @@
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"definition": "label_values(hindsight_http_requests_total, tenant)",
"hide": 0,
"includeAll": true,
@@ -1295,10 +1246,7 @@
"multi": false,
"name": "tenant",
"options": [],
"query": {
"query": "label_values(hindsight_http_requests_total, tenant)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"query": "label_values(hindsight_http_requests_total, tenant)",
"refresh": 2,
"regex": "",
"skipUrlSync": false,
@@ -9,10 +9,7 @@
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -54,10 +51,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -99,10 +93,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -145,10 +136,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -191,10 +179,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -269,10 +254,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -361,10 +343,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -439,10 +418,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -527,6 +503,20 @@
"tags": ["hindsight", "llm"],
"templating": {
"list": [
{
"current": {},
"hide": 0,
"includeAll": false,
"label": "Data source",
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
},
{
"allValue": ".*",
"current": {
@@ -534,10 +524,7 @@
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"definition": "label_values(hindsight_llm_calls_total, tenant)",
"hide": 0,
"includeAll": true,
@@ -545,10 +532,7 @@
"multi": false,
"name": "tenant",
"options": [],
"query": {
"query": "label_values(hindsight_llm_calls_total, tenant)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"query": "label_values(hindsight_llm_calls_total, tenant)",
"refresh": 2,
"regex": "",
"skipUrlSync": false,
@@ -9,10 +9,7 @@
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -54,10 +51,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -99,10 +93,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -145,10 +136,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -191,10 +179,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -237,10 +222,7 @@
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -328,10 +310,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -429,10 +408,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -507,10 +483,7 @@
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
@@ -590,6 +563,20 @@
"tags": ["hindsight"],
"templating": {
"list": [
{
"current": {},
"hide": 0,
"includeAll": false,
"label": "Data source",
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
},
{
"allValue": ".*",
"current": {
@@ -597,10 +584,7 @@
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"datasource": "$datasource",
"definition": "label_values(hindsight_operation_operations_total, tenant)",
"hide": 0,
"includeAll": true,
@@ -608,10 +592,7 @@
"multi": false,
"name": "tenant",
"options": [],
"query": {
"query": "label_values(hindsight_operation_operations_total, tenant)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"query": "label_values(hindsight_operation_operations_total, tenant)",
"refresh": 2,
"regex": "",
"skipUrlSync": false,