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

Update grafana-datasource-template #787

Merged
merged 10 commits into from
Mar 8, 2021
40 changes: 12 additions & 28 deletions cost-analyzer/templates/grafana-datasource-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
namespace: {{ $.Values.grafana.namespace_datasources }}
{{- end }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- if $.Values.grafana.sidecar.datasources.label }}
{{ $.Values.grafana.sidecar.datasources.label }}: "1"
{{- else }}
Expand All @@ -25,45 +25,29 @@ data:
apiVersion: 1
datasources:
- access: proxy
{{- if .Values.global.thanos }}
{{- if .Values.global.thanos.enabled }}
name: {{ default "Prometheus" .Values.grafana.sidecar.datasources.dataSourceName }}
isDefault: false
{{- else }}
name: "default-kubecost"
{{- if .Values.grafana.sidecar.datasources.defaultDatasourceEnabled }}
isDefault: true
{{- else }}
isDefault: false
{{- end }}
{{- end }}
{{- else }}
name: "default-kubecost"
name: default-kubecost
type: prometheus
{{- if .Values.grafana.sidecar.datasources.defaultDatasourceEnabled }}
isDefault: true
{{- else }}
isDefault: false
{{- end }}
{{- end }}
type: prometheus
{{- if .Values.global.thanos }}
{{- if .Values.global.thanos.enabled }}
{{- if .Values.global.prometheus.enabled }}
url: http://{{ template "cost-analyzer.prometheus.server.name" . }}.{{ .Release.Namespace }}
url: http://{{ .Release.Name }}-thanos-query-http.{{ .Release.Namespace }}:{{ .Values.thanos.query.http.port }}
{{- else }}
url: {{ .Values.global.prometheus.fqdn }}
url: {{ .Values.global.thanos.queryService }}
{{- end }}
{{- if .Values.global.thanos.enabled }}
- access: proxy
name: "default-kubecost"
type: prometheus
{{- if .Values.grafana.sidecar.datasources.defaultDatasourceEnabled }}
isDefault: true
{{- else }}
name: {{ default "Prometheus" .Values.grafana.sidecar.datasources.dataSourceName}}
isDefault: false
type: prometheus
{{- end }}
{{- if .Values.global.prometheus.enabled }}
url: http://{{ .Release.Name }}-thanos-query-http.{{ .Release.Namespace }}:{{ .Values.thanos.query.http.port }}
{{ else }}
url: {{ .Values.global.thanos.queryService }}
url: http://{{ template "cost-analyzer.prometheus.server.name" . }}.{{ .Release.Namespace }}
{{- else }}
url: {{ .Values.global.prometheus.fqdn }}
{{- end }}
{{- end }}
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ grafana:
# dataSourceFilename: foo.yml # If you need to change the name of the datasource file
enabled: true
defaultDatasourceEnabled: false
dataSourceName: default-kubecost
dataSourceName: prometheus-kubecost
# label that the configmaps with datasources are marked with
label: kubecost_grafana_datasource
# For grafana to be accessible, add the path to root_url. For example, if you run kubecost at www.foo.com:9090/kubecost
Expand Down