Difference between revisions of "Setup SMTP in Grafana"

From Gejoreuy
Jump to navigation Jump to search
 
(15 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
== Step by Step ==
 
== Step by Step ==
  
1. Prepare our Gmail account to '''allow less secure apps''' option.
+
=== Step 1 : Prepare Gmail Account ===
<br>Just go to https://myaccount.google.com/lesssecureapps and set allow less secure apps to ON.
+
 
<br>
+
Just go to <code>https://myaccount.google.com/lesssecureapps</code> and set <code>Allow less secure apps</code> to <code>ON</code>.
<br>2. Update and install SSMTP in Grafana server.
+
<br>We need to do this to our Gmail account to make it can receive connections from external programs.
<pre>
+
<br>If we use corporate SMTP, just contact our IT support to do the same.
# sudo apt-get update
+
 
# sudo apt-get install ssmtp
+
=== Step 2 : Update and install SSMTP ===
</pre>
+
 
 +
We'll update our Grafana server and install SMTP on it.
 +
 
 +
root@gejoreuy:~# sudo apt-get update
 +
root@gejoreuy:~# sudo apt-get install ssmtp
 +
 
 +
=== Step 3 : Edit SSMTP Configuration ===
 +
 
 +
Go to <code>/etc/ssmtp/</code> directory and edit <code>ssmtp.conf</code> file like below configuration.
 +
 
 +
root@gejoreuy:~# vi /etc/ssmtp/ssmtp.conf
 +
root=gejoreuy@gmail.com
 +
mailhub=smtp.gmail.com:587
 +
FromLineOverride=YES
 +
AuthUser=gejoreuy@gmail.com
 +
AuthPass=MyPassword
 +
UseTLS=YES
 +
UseSTARTTLS=YES
 +
 
 +
In our example, we are using the Gmail account <code>gejoreuy@gmail.com</code> with password <code>MyPassword</code>.
 +
 
 +
=== Step 4 : Test SMTP Server ===
 +
 
 +
Use the following command to send an email using the command-line.
 +
 
 +
root@gejoreuy:~# echo "E-Mail using the command-line" | ssmtp gejoreuy@gmail.com
 +
 
 +
Check our inbox for the test message that we just sent.
 +
<br>If the test was successfully, we may use our Grafana with SMTP.

Latest revision as of 08:24, 9 March 2021

Introduction

Grafana is a tools for visualisation dashboard monitoring which work together with various datasource.
In its use, we'll need SMTP activated to do some functionality like email alerting, notification, or invitation request.

Assumptions

In this page, we assumed that we already know about Grafana and have it run in a server.
In our example, we are going to use Google Gmail as SMTP server.

Step by Step

Step 1 : Prepare Gmail Account

Just go to https://myaccount.google.com/lesssecureapps and set Allow less secure apps to ON.
We need to do this to our Gmail account to make it can receive connections from external programs.
If we use corporate SMTP, just contact our IT support to do the same.

Step 2 : Update and install SSMTP

We'll update our Grafana server and install SMTP on it.

root@gejoreuy:~# sudo apt-get update
root@gejoreuy:~# sudo apt-get install ssmtp

Step 3 : Edit SSMTP Configuration

Go to /etc/ssmtp/ directory and edit ssmtp.conf file like below configuration.

root@gejoreuy:~# vi /etc/ssmtp/ssmtp.conf
root=gejoreuy@gmail.com
mailhub=smtp.gmail.com:587
FromLineOverride=YES
AuthUser=gejoreuy@gmail.com
AuthPass=MyPassword
UseTLS=YES
UseSTARTTLS=YES

In our example, we are using the Gmail account gejoreuy@gmail.com with password MyPassword.

Step 4 : Test SMTP Server

Use the following command to send an email using the command-line.

root@gejoreuy:~# echo "E-Mail using the command-line" | ssmtp gejoreuy@gmail.com

Check our inbox for the test message that we just sent.
If the test was successfully, we may use our Grafana with SMTP.