Skip to content

Commit e887a99

Browse files
committed
add note about dynamic referencing/linking
1 parent 1deb13f commit e887a99

File tree

1 file changed

+129
-4
lines changed

1 file changed

+129
-4
lines changed

docs/docs/proposals/006-grafanalibrarypanel-crd.md docs/docs/proposals/007-grafanalibrarypanel-crd.md

+129-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ metadata:
5757
spec:
5858
allowCrossNamespaceImport: true
5959
contentCacheDuration: 1m0s
60-
folder: shared
60+
folderRef: folder-ref
6161
instanceSelector:
6262
matchLabels:
6363
env: dev
@@ -67,6 +67,8 @@ spec:
6767
6868
### Referencing in Dashboards
6969
70+
#### Static referencing
71+
7072
When GrafanaLibraryPanels are configured for a Grafana instance, users will be able to browse
7173
and utilize library panels in dashboards via the GUI workflows. They can export the JSON model
7274
of the dashboard and store the model in a GrafanaDashboard CR, if desired. Library panels are
@@ -95,9 +97,132 @@ custom resource. It can thus be provided by the CR owner. By setting the UID to
9597
as opposed to letting Grafana autogenerate it, it's possible to provision both Library Panels
9698
and Dashboards that reference them as CRs.
9799

98-
In the future we could have more ways of dynamically linking in library panels via the operator,
99-
where it can look up the UIDs and rewrite placeholder tokens in the dashboard model, if desired.
100-
Such extensions are out of this proposal's scope.
100+
#### Dynamic referencing
101+
102+
Similar to how Datasources can be dynamically referenced via the
103+
`.spec.datasources` field, we can extend the GrafanaDashboard CR to similarly
104+
allow mapping library panels via a new `.spec.libraryPanels` field structured
105+
very similarly. The CR author can specify a replacement string and a reference
106+
to the library panel deployed itself as a CR.
107+
108+
When reconciling the GrafanaDashboard, the controller will fetch the dependent
109+
GrafanaLibraryPanel CRs, look up their UIDs, and then perform the string
110+
replacement.
111+
112+
```yaml
113+
apiVersion: grafana.integreatly.org/v1beta1
114+
kind: GrafanaDashboard
115+
metadata:
116+
name: grpc-overview
117+
spec:
118+
libraryPanels:
119+
- inputName: "LP_GRPC_SUCCESS_RATE"
120+
libraryPanelRef: "grpc-server-success-rate"
121+
allowCrossNamespaceImport: true
122+
contentCacheDuration: 1m0s
123+
folderRef: folder-ref
124+
instanceSelector:
125+
matchLabels:
126+
env: dev
127+
region: us-central1
128+
json: >
129+
{
130+
"__inputs": [
131+
{
132+
"name": "DS_PROMETHEUS",
133+
"label": "prometheus",
134+
"description": "",
135+
"type": "datasource",
136+
"pluginId": "prometheus",
137+
"pluginName": "Prometheus"
138+
}
139+
],
140+
"__elements": {},
141+
"__requires": [
142+
{
143+
"type": "grafana",
144+
"id": "grafana",
145+
"name": "Grafana",
146+
"version": "9.1.6"
147+
},
148+
{
149+
"type": "datasource",
150+
"id": "prometheus",
151+
"name": "Prometheus",
152+
"version": "1.0.0"
153+
},
154+
{
155+
"type": "panel",
156+
"id": "timeseries",
157+
"name": "Time series",
158+
"version": ""
159+
}
160+
],
161+
"annotations": {
162+
"list": [
163+
{
164+
"builtIn": 1,
165+
"datasource": {
166+
"type": "grafana",
167+
"uid": "-- Grafana --"
168+
},
169+
"enable": true,
170+
"hide": true,
171+
"iconColor": "rgba(0, 211, 255, 1)",
172+
"name": "Annotations & Alerts",
173+
"target": {
174+
"limit": 100,
175+
"matchAny": false,
176+
"tags": [],
177+
"type": "dashboard"
178+
},
179+
"type": "dashboard"
180+
}
181+
]
182+
},
183+
"editable": true,
184+
"fiscalYearStartMonth": 0,
185+
"graphTooltip": 1,
186+
"id": null,
187+
"links": [],
188+
"liveNow": false,
189+
"panels": [
190+
{
191+
"gridPos": {
192+
"h": 8,
193+
"w": 12,
194+
"x": 0,
195+
"y": 0
196+
},
197+
"id": 2,
198+
"libraryPanel": {
199+
"uid": "${LP_GRPC_SERVER_SUCCESS_RATE}",
200+
"name": "gRPC Server Success Rate"
201+
}
202+
}
203+
],
204+
"refresh": "5s",
205+
"schemaVersion": 37,
206+
"style": "dark",
207+
"tags": [],
208+
"templating": {
209+
"list": []
210+
},
211+
"time": {
212+
"from": "now-6h",
213+
"to": "now"
214+
},
215+
"timepicker": {
216+
"refresh_intervals": [],
217+
"time_options": []
218+
},
219+
"timezone": "browser",
220+
"title": "gRPC Overview",
221+
"uid": "10605d5d-da66-4bb0-a77a-2635fae239f7",
222+
"version": 3,
223+
"weekStart": ""
224+
}
225+
```
101226
102227
### Generalize Dashboard content read/cache logic
103228

0 commit comments

Comments
 (0)