diff --git a/cost-analyzer/templates/grafana-datasource-template.yaml b/cost-analyzer/templates/grafana-datasource-template.yaml index e79d2fa35..d92a95023 100644 --- a/cost-analyzer/templates/grafana-datasource-template.yaml +++ b/cost-analyzer/templates/grafana-datasource-template.yaml @@ -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 }} @@ -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 -}} diff --git a/cost-analyzer/values.yaml b/cost-analyzer/values.yaml index a72776ae8..17ef8782f 100755 --- a/cost-analyzer/values.yaml +++ b/cost-analyzer/values.yaml @@ -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