giantswarm / prometheus

Kubernetes Setup for Prometheus and Grafana
Apache License 2.0
858 stars 424 forks source link

SMTP configuration not loading #128

Open migarol opened 5 years ago

migarol commented 5 years ago

I cloned the repo and edited the following files with my Mailgun credentials but when i go to Grafana Server Setting, i still see SMTP not enabled and default values.

manifests/alertmanager/configmap.yaml manifests-all.yaml

Any idea where and how to enable smtp ?

fuminori-ido commented 4 years ago

Hi,

Grafana SMTP setting is different from alertmanager's one.

Grafana config is described here In general: https://grafana.com/docs/installation/configuration/

To pass these values in grafana pod, I added followings at 'env' 427-th line at manifests-all.yaml:

...
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: grafana-core
  namespace: monitoring
  labels:
    app: grafana
    component: core
spec:
  ...
  template:
    metadata:
      labels:
        app: grafana
        component: core
    spec:
      containers:
      - image: grafana/grafana:6.3.5
        ...
        env:
          - name: GF_AUTH_BASIC_ENABLED
            ...
          # SMTP setting
          - name:               GF_SMTP_ENABLED
            value:              'true'
          - name:               GF_SMTP_SKIP_VERIFY
            value:              'true'
          - name:               GF_SMTP_HOST
            valueFrom:
              configMapKeyRef:
                name:           grafana-configmap
                key:            GF_SMTP_HOST
          - name:               GF_SMTP_FROM_ADDRESS
            valueFrom:
              configMapKeyRef:
                name:           grafana-configmap
                key:            GF_SMTP_FROM_ADDRESS
          - name:               GF_SMTP_USER
            valueFrom:
              secretKeyRef:
                name:           grafana-secret
                key:            GF_SMTP_USER
          - name:               GF_SMTP_PASSWORD
            valueFrom:
              secretKeyRef:
                name:           grafana-secret
                key:            GF_SMTP_PASSWORD

And define these values at additional ConfigMap and Secret like the followings:

---
apiVersion:             v1
kind:                   Namespace
metadata:
  name:                 monitoring
---
apiVersion:             v1
kind:                   ConfigMap
metadata:
  name:                 grafana-configmap
  namespace:            monitoring
data:
  GF_SERVER_DOMAIN:     ...
  GF_SMTP_ENABLED:      "true"
  GF_SMTP_HOST:         ...
  GF_SMTP_FROM_ADDRESS: ...
---
apiVersion:             v1
kind:                   Secret
metadata:
  name:                 grafana-secret
  namespace:            monitoring
stringData:
  GF_SMTP_USER:         ...
  GF_SMTP_PASSWORD:     ...

Hope this helps