2 # Copyright 2018 Intel Corporation, Inc
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 {{- if .Values.global.grafana.enabled -}}
22 name: {{ include "common.fullname" . }}
23 namespace: {{ include "common.namespace" . }}
25 app: {{ include "common.name" . }}
26 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27 release: {{ include "common.release" . }}
28 heritage: {{ .Release.Service }}
30 {{ tpl (.Files.Glob "resources/config/*").AsConfig . | indent 2 }}
32 {{- if .Values.datasources }}
33 {{- range $key, $value := .Values.datasources }}
35 {{ toYaml $value | indent 4 }}
39 {{- if .Values.dashboardProviders }}
40 {{- range $key, $value := .Values.dashboardProviders }}
42 {{ toYaml $value | indent 4 }}
46 {{- if .Values.dashboards }}
47 download_dashboards.sh: |
50 {{- if .Values.dashboardProviders }}
51 {{- range $key, $value := .Values.dashboardProviders }}
52 {{- range $value.providers }}
53 mkdir -p {{ .options.path }}
57 {{- range $provider, $dashboards := .Values.dashboards }}
58 {{- range $key, $value := $dashboards }}
59 {{- if (or (hasKey $value "gnetId") (hasKey $value "url")) }}
61 --connect-timeout 60 \
63 -H "Accept: application/json" \
64 -H "Content-Type: application/json;charset=UTF-8" \
65 {{- 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 }} \
66 > /var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json
72 {{- if .Values.dashboards }}
73 {{- range $provider, $dashboards := .Values.dashboards }}
78 name: {{ include "common.fullname" $ }}-dashboards-{{ $provider }}
79 namespace: {{ include "common.namespace" $ }}
81 app: {{ include "common.name" $ }}
82 chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
83 release: {{ include "common.release" $ }}
84 heritage: {{ $.Release.Service }}
85 dashboard-provider: {{ $provider }}
87 {{- range $key, $value := $dashboards }}
88 {{- if hasKey $value "json" }}
90 {{ $value.json | indent 4 }}