Dashboard - configJson with ${env}
mariusz-gomse-centra opened this issue · 1 comments
mariusz-gomse-centra commented
- Create Dashboard object
- In configJson put json with ${env} (which is datasource from variable) - this json was generated by grafana
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 197,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${env}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"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",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unitScale": true
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${env}"
},
"expr": "",
"instant": false,
"range": true,
"refId": "A"
}
],
"title": "Panel Title",
"type": "timeseries"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": [
{
"current": {
},
"hide": 0,
"includeAll": false,
"multi": false,
"name": "env",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Example",
"uid": "example-ddbk54g5im39cd",
"version": 1,
"weekStart": ""
}
- apply to k8s
You'll get an error like below and dashboard won't be synced:
Warning CannotObserveExternalResource 2m38s (x21 over 17m) managed/oss.grafana.crossplane.io/v1alpha1, kind=dashboard cannot run refresh: refresh failed: Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.
Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.
If you change in configJson ${env} to something
then everything is OK (but you won't have dynamic datasource in panel)
mariusz-gomse-centra commented
I'm closing this because after creation I found out that there is other issue for it: #59 (and solution is also there)