Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grafana] cannot import a dashboard with multiple datasources from grafana.com #313

Closed
TagadaPoe opened this issue Mar 16, 2021 · 4 comments · Fixed by #1881
Closed

[grafana] cannot import a dashboard with multiple datasources from grafana.com #313

TagadaPoe opened this issue Mar 16, 2021 · 4 comments · Fixed by #1881

Comments

@TagadaPoe
Copy link

The following code is the section of the bash script that downloads a dashboard from Grafana:

    {{- if $value.url -}}"{{ $value.url }}"{{- else -}}"https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download"{{- end -}}{{ if $value.datasource }} | sed '/-- .* --/! s/"datasource":.*,/"datasource": "{{ $value.datasource }}",/g'{{ end }}{{- if $value.b64content -}} | base64 -d {{- end -}} \
    > "/var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json"
      {{- end -}}
    {{- end }}

The sed command replaces ALL datasources with the single datasource provided in values, if present.

Expected behaviour

We should be able to specify multiple datasources in the chart values and replace each datasource with the right datasource.

If the dashboard was exported with the "external" checkbox enabled, then we sould be able to replace the datasource based on the variable name (e.g, replace "${DS_PROMETHEUS}" by the actual datasource name).

@lemaral
Copy link

lemaral commented May 14, 2021

For example the Loki quick search dashboard cannot be imported correctly: https://grafana.com/grafana/dashboards/12019

@kodeine
Copy link

kodeine commented Aug 1, 2021

Any updates on this?

@FrankGiesecke
Copy link

Did anyone found a solution for this problem?
I run the the same problem like @lemaral with https://grafana.com/grafana/dashboards/12019

@igor-pinchuk
Copy link

It is not clear how one should be importing any of the dashboards that have multiple data sources.
In my case these two dashboards:
https://grafana.com/grafana/dashboards/14055
https://grafana.com/grafana/dashboards/12019

Probably there are many more dashboards that have more than one data source.

In the helm chart values we can provide only one data source, e.g:

loki-stack-monitoring:
    gnetId: 14055
    datasource: Prometheus

This bug makes many dashboards incompatible with projects that use grafana chart as a dependency (kube-prometheus-stack in my case).

It is very strange that issue like this (which was reported more than a year ago) still has not attracted any attention from maintainers and there are very few people interested in it... probably nobody uses grafana in combination with Loki...

jfcoz added a commit to jfcoz/grafana-helm-charts that referenced this issue Oct 10, 2022
jfcoz added a commit to jfcoz/grafana-helm-charts that referenced this issue Oct 10, 2022
Fix grafana#313

Signed-off-by: Julien Francoz <julien-github@francoz.net>
paolopiaggio pushed a commit to paolopiaggio/helm-charts that referenced this issue Oct 12, 2022
Fix grafana#313

Signed-off-by: Julien Francoz <julien-github@francoz.net>
Signed-off-by: paolopiaggio <paolo.piaggesi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants