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] Improve dashboards download script #3350

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/grafana/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: grafana
version: 8.5.5
version: 8.5.6
appVersion: 11.2.2
kubeVersion: "^1.8.0-0"
description: The leading tool for querying and visualizing time series and metrics.
Expand Down
4 changes: 3 additions & 1 deletion charts/grafana/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ download_dashboards.sh: |
{{- range $provider, $dashboards := .Values.dashboards }}
{{- range $key, $value := $dashboards }}
{{- if (or (hasKey $value "gnetId") (hasKey $value "url")) }}
curl -skf \
echo "downloading: {{ $key }} dashboard"
echo "Source Url: {{ include "grafana.url" . }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Source Url: {{ include "grafana.url" . }}
echo "Source URL: {{ include "grafana.dashboard-dowload-url" . }}

curl -skf --show-error \
--connect-timeout 60 \
--max-time 60 \
{{- if not $value.b64content }}
Expand Down
10 changes: 10 additions & 0 deletions charts/grafana/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ Formats imagePullSecrets. Input is (dict "root" . "imagePullSecrets" .{specific
{{- $secretFound}}
{{- end -}}


{{/*
Define the source URL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the template to the curl command!

*/}}
{{- define "grafana.url" -}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- define "grafana.url" -}}
{{- define "grafana.dashboard-dowload-url" -}}

{{- $this_revision := hasKey . "revision" | ternary .revision 1 }}
{{- $this_url := hasKey . "url" | ternary .url (printf "https://grafana.com/api/dashboards/%s/revisions/%s/download" .gnetId $this_revision) }}
{{- print $this_url }}
{{- end }}

{{/*
Checks whether the user is attempting to store secrets in plaintext
in the grafana.ini configmap
Expand Down
2 changes: 1 addition & 1 deletion charts/grafana/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ initContainers:
{{- end }}
imagePullPolicy: {{ .Values.downloadDashboardsImage.pullPolicy }}
command: ["/bin/sh"]
args: [ "-c", "mkdir -p /var/lib/grafana/dashboards/default && /bin/sh -x /etc/grafana/download_dashboards.sh" ]
args: [ "-c", "mkdir -p /var/lib/grafana/dashboards/default && /bin/sh /etc/grafana/download_dashboards.sh" ]
{{- with .Values.downloadDashboards.resources }}
resources:
{{- toYaml . | nindent 6 }}
Expand Down
Loading