grafana-operator
grafana-operator copied to clipboard
[Bug] Operator does not correctly import dashboards with variables
*Description
The Operator does not correctly set up a variable defined in the __inputs section of a dashboard
Version v5.4.2
To Reproduce Steps to reproduce the behavior:
-
Set up a Grafana instance on kind in the usual way.
-
use
kubectl apply -fto apply the attached dashboard : test-dashboard.yaml.gz -
Log into Grafana and notice that the panel shows
${VAR_TESTCONSTANT}instead of the expected valueexample-constant.
Expected behavior
When Grafana is importing the dashboard it should inflate the variables within the __inputs section.
Screenshots
Expected outcome :
Observed outcome :
Runtime (please complete the following information):
- OS: Fedora 38
- v5.4.2
- Environment: kind 0.20.0/kubernetes1.27.3
- Deployment type: local
Same issue here with Grafana-Operator v5.4.1 and Grafana v10.1.4.
@bheading isn't __inputs used for specifying data sources? Also, should the values reference environment variables?
@pb82 But if so, how can we overwrite template variables in Grafana dashboards with the operator? @NissesSenap Do you have any idea?
Its possible to use grafanadashboard.spec.datasources to map a value to a constant defined in __inputs
Not sure if this if is an officially recommended approach though, it would be preferable not to have to reference a field named datasourceName.
--- test-dashboard.yaml 2023-12-19 10:43:02.693241401 +0100
+++ test-dashboard2.yaml 2023-12-19 11:12:39.567848239 +0100
@@ -6,9 +6,9 @@
instanceSelector:
matchLabels:
dashboards: grafana-a
- envs:
- - name: VAR_TESTCONSTANT
- value: foobar
+ datasources:
+ - inputName: VAR_TESTCONSTANT
+ datasourceName: foobar
json: |
{
"__inputs": [
I currently don't have time to take a deeper look, at this. But I would recommend looking at the documentation. That is working last time I looked.
This issue hasn't been updated for a while, marking as stale, please respond within the next 7 days to remove this label
/remove-lifecycle stale This is still a issue but there is a workaround, thanks to @ciomaire
This issue hasn't been updated for a while, marking as stale, please respond within the next 7 days to remove this label