grafana-operator icon indicating copy to clipboard operation
grafana-operator copied to clipboard

[Bug] Operator does not correctly import dashboards with variables

Open bheading opened this issue 1 year ago • 7 comments

*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:

  1. Set up a Grafana instance on kind in the usual way.

  2. use kubectl apply -f to apply the attached dashboard : test-dashboard.yaml.gz

  3. Log into Grafana and notice that the panel shows ${VAR_TESTCONSTANT} instead of the expected value example-constant.

Expected behavior

When Grafana is importing the dashboard it should inflate the variables within the __inputs section.

Screenshots

Expected outcome :

image

Observed outcome :

image

Runtime (please complete the following information):

  • OS: Fedora 38
  • v5.4.2
  • Environment: kind 0.20.0/kubernetes1.27.3
  • Deployment type: local

bheading avatar Nov 08 '23 23:11 bheading

Same issue here with Grafana-Operator v5.4.1 and Grafana v10.1.4.

R-Studio avatar Nov 13 '23 15:11 R-Studio

@bheading isn't __inputs used for specifying data sources? Also, should the values reference environment variables?

pb82 avatar Nov 28 '23 12:11 pb82

@pb82 But if so, how can we overwrite template variables in Grafana dashboards with the operator? @NissesSenap Do you have any idea?

R-Studio avatar Dec 19 '23 07:12 R-Studio

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": [

ciomaire avatar Dec 19 '23 10:12 ciomaire

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.

nissessenap avatar Dec 19 '23 13:12 nissessenap

This issue hasn't been updated for a while, marking as stale, please respond within the next 7 days to remove this label

github-actions[bot] avatar Jan 19 '24 01:01 github-actions[bot]

/remove-lifecycle stale This is still a issue but there is a workaround, thanks to @ciomaire

R-Studio avatar Jan 25 '24 09:01 R-Studio

This issue hasn't been updated for a while, marking as stale, please respond within the next 7 days to remove this label

github-actions[bot] avatar Feb 25 '24 01:02 github-actions[bot]