Skip to content

Commit 3ebc267

Browse files
authored
Add docs for configuring SMTP in Grafana (for email alerts) (#2219)
1 parent 6ca1708 commit 3ebc267

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

docs/clusters/observability/alerting.md

+48
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,51 @@ Your dashboard now has stored the alert configuration permanently.
114114
## Multiple APIs alerts
115115

116116
Due to how Grafana was built, you'll need to re-do the steps of setting a given alert for each individual API. That's because Grafana doesn't currently support alerts on template or transformation queries.
117+
118+
## Enabling email alerts
119+
120+
It is possible to manually configure SMTP to enable email alerts (we plan on automating this proccess, see [#2210](https://github.com/cortexlabs/cortex/issues/2210)).
121+
122+
**Step 1**
123+
124+
Install [kubectl](../advanced/kubectl.md).
125+
126+
**Step 2**
127+
128+
```bash
129+
kubectl create secret generic grafana-smtp \
130+
--from-literal=GF_SMTP_ENABLED=true \
131+
--from-literal=GF_SMTP_HOST=<SMTP-HOST> \
132+
--from-literal=GF_SMTP_USER=<EMAIL-ADDRESS> \
133+
--from-literal=GF_SMTP_FROM_ADDRESS=<EMAIL-ADDRESS> \
134+
--from-literal=GF_SMTP_PASSWORD=<EMAIL-PASSWORD>
135+
```
136+
137+
The `<SMTP-HOST>` varies from provider to provider (e.g. Gmail's is `smtp.gmail.com:587`).
138+
139+
**Step 3**
140+
141+
Edit Grafana's statefulset by running `kubectl edit statefulset grafana` (this will open a code editor). Inside the container named `grafana` (in the `containers` section), add an `envFrom` section that will mount the SMTP secret. Here is an example of what it looks like after the addition:
142+
143+
```yaml
144+
# ...
145+
containers:
146+
- env:
147+
- name: GF_SERVER_ROOT_URL
148+
value: '%(protocol)s://%(domain)s:%(http_port)s/dashboard'
149+
- name: GF_SERVER_SERVE_FROM_SUB_PATH
150+
value: "true"
151+
- name: GF_USERS_DEFAULT_THEME
152+
value: light
153+
envFrom:
154+
- secretRef:
155+
name: grafana-smtp
156+
image: quay.io/cortexlabs/grafana:0.35
157+
imagePullPolicy: IfNotPresent
158+
name: grafana
159+
# ...
160+
```
161+
162+
Save and close your editor.
163+
164+
It will take 30-60 seconds for Grafana to restart, after which you can access the dashboard. You can check the logs with `kubectl logs -f grafana-0`.

0 commit comments

Comments
 (0)