[stable/Grafana] Smtp setup not reading host and other values
Context: Setting up Grafana with SMTP setup.
Steps followed
- Create kubernetes secret with user, password, host.
kubectl create secret generic smtp-secret --from-literal=user=username --from literal=host=mailtrap.io:2525 --from-literal=password=password - Install grafana
helm upgrade --install grafana stable/grafana --set image.tag=5.1.0,smtp.existingSecret="smtp-secret"
Then on the logs, the following is shown
t=2018-06-20T07:52:19+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_SMTP_USER=username" t=2018-06-20T07:52:19+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_SMTP_PASSWORD=*********" t=2018-06-20T07:52:19+0000 lvl=info msg="Path Home" logger=settings path=/usr/share/grafana t=2018-06-20T07:52:19+0000 lvl=info msg="Path Data" logger=settings path=/var/lib/grafana
The GF_SMTP_HOST variable is not populated, causing smtp setup to be incomeplete.
on checking the deployment.yaml found this. https://github.com/kubernetes/charts/blob/314995906eb53319a423ee22146664d086689556/stable/grafana/templates/deployment.yaml#L159
{{- if .Values.smtp.existingSecret }}
- name: GF_SMTP_USER
valueFrom:
secretKeyRef:
name: {{ .Values.smtp.existingSecret }}
key: user
- name: GF_SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.smtp.existingSecret }}
key: password
{{- end }}
I dont see anyother value required for the config being set as ENV in the code like host. Also the value is added to grafana.ini file either.
The documentaion doesn't seem to provide any insight on this. Please help me figure this out.
Figured out the way. By supplying json with grafana.ini key and SMTP values
Can you provide an working example please.
{
"grafana.ini":{
"smtp": {
"enabled": true,
"host" :"<hostname goes here>",
"user" : "<username goes here>",
"password" : "<password goes here>"
}
}
}
Pass the above config while installing/upgrading. It should start working.
helm install --name my-release stable/grafana -f <path-to-json-file>
How this could look in the values.yml file? Because I am calling helm like this: helm install --name grafa --namespace monitoring -f values.yaml stable/grafana Thank you!

- I have added the below in my grafana values file.
| grafana.ini | Grafana's primary configuration | { "smtp": { "enabled": true, "host" :"<hostname goes here>", "user" : "<username goes here>", "password" : "<password goes here>" } |
- Also added in the smtp section in the values file.
smtp: enabled: true host: "host" user: "Username" password: "Password"
helm install stable/grafana --name grafana --namespace grafana -f values.yaml
I am not able to send alerts, Also in the grafana portal. I see the SMTP option is disabled.
For me this is working with gmail.
grafana.ini:
smtp:
enabled: true
host: "smtp.gmail.com:587"
user: "[email protected]"
password: "pass"
With this Helm Chart
apiVersion: v1
name: grafana
version: 3.0.0
appVersion: 6.0.2
i still do get issues with smtp not reading my secret the point of creating the secret is to not have the password in the values.yaml.
smtp:
enabled: true
existingSecret: "smtp-secret"
Hi,
Grafana SMTP settings are not updated in the dashboard, Downloaded Grafana Chart Edited values and Configmaps.yaml file to include SMTP settings. Included the below lines
-
Configmap.yaml {{- if .Values.smtp }} {{- range $key, $value := .Values.smtp }} {{ $key }}: | {{ toYaml $value | indent 4 }} {{- end -}} {{- end -}}
-
Values.yaml grafana.ini: paths: data: /var/lib/grafana/data logs: /var/log/grafana plugins: /var/lib/grafana/plugins provisioning: /etc/grafana/provisioning smtp: enabled: true existingSecret: "" host: "smtpserver:port" userKey: "user" passwordKey: "password"
Create Secret for Username and Password using
kubectl create secret generic smtp-secret --from-literal=user="Mailid" --from-literal=password="password" -n monitoring
Installed the helm chart which is modified
Able to see the SMTP Settings as enabled.
he
Hi,
Grafana SMTP settings are not updated in the dashboard, Downloaded Grafana Chart Edited values and Configmaps.yaml file to include SMTP settings. Included the below lines
- Configmap.yaml {{- if .Values.smtp }} {{- range $key, $value := .Values.smtp }} {{ $key }}: | {{ toYaml $value | indent 4 }} {{- end -}} {{- end -}}
- Values.yaml grafana.ini: paths: data: /var/lib/grafana/data logs: /var/log/grafana plugins: /var/lib/grafana/plugins provisioning: /etc/grafana/provisioning smtp: enabled: true existingSecret: "" host: "smtpserver:port" userKey: "user" passwordKey: "password"
Create Secret for Username and Password using
kubectl create secret generic smtp-secret --from-literal=user="Mailid" --from-literal=password="password" -n monitoring
Installed the helm chart which is modified
Able to see the SMTP Settings as enabled.
can we add without adding secret name in exsistingSecret?
yes you can add it
existingSecret: "smtp-secret"
the one in values.yml works but you will need to include the port with stmp host. othervise it will not configure smtp and ignore ur smtp settings all together