charts icon indicating copy to clipboard operation
charts copied to clipboard

[stable/Grafana] Smtp setup not reading host and other values

Open ananthunair opened this issue 8 years ago • 11 comments

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.

ananthunair avatar Jun 20 '18 11:06 ananthunair

Figured out the way. By supplying json with grafana.ini key and SMTP values

ananthunair avatar Jun 21 '18 09:06 ananthunair

Can you provide an working example please.

Tim-Schwalbe avatar Jul 23 '18 14:07 Tim-Schwalbe

{ "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>

ananthunair avatar Jul 24 '18 04:07 ananthunair

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!

image

Tim-Schwalbe avatar Jul 30 '18 05:07 Tim-Schwalbe

  1. 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>" } |

  1. 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.

Lavanya-Balaji avatar May 29 '19 08:05 Lavanya-Balaji

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

Tim-Schwalbe avatar May 29 '19 09:05 Tim-Schwalbe

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"

Moofasax avatar May 30 '19 18:05 Moofasax

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

  1. Configmap.yaml {{- if .Values.smtp }} {{- range $key, $value := .Values.smtp }} {{ $key }}: | {{ toYaml $value | indent 4 }} {{- end -}} {{- end -}}

  2. 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.

Lavanya-Balaji avatar May 31 '19 11:05 Lavanya-Balaji

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

  1. Configmap.yaml {{- if .Values.smtp }} {{- range $key, $value := .Values.smtp }} {{ $key }}: | {{ toYaml $value | indent 4 }} {{- end -}} {{- end -}}
  2. 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?

hanzala1234 avatar Jun 18 '19 14:06 hanzala1234

yes you can add it

existingSecret: "smtp-secret"

Lavanya-Balaji avatar Jun 20 '19 09:06 Lavanya-Balaji

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

iahmad-khan avatar Dec 05 '19 11:12 iahmad-khan