This tutorial will show you how to integrate Monika with SMTP so you can receive notifications from Monika straight to your email.
In order to start using Google Mail as your Monika notification channel, you need to prepare these:
First, go to the Less secure app access section of your Google Account. You might need to sign in first using your Google account. Then, turn on the “Allow less secure apps” like so:
Now that we enabled the ‘Allow less secure apps’ option, it is time to create a Monika configuration. As an example, let’s use a configuration from our previous article: Be alerted when your authentication API is slow with Monika: A guide for chaining request
The configuration above will hit the /login endpoint with a JSON request body and hit an API using the token from the previous request’s response in the Authorization header. If you look closely in the notifications block, it only shows you desktop notifications when an alert is triggered. What we are going to do is to add a new notification channel, which is SMTP. Here is an example of an SMTP notification block:
["email@example.com", "firstname.lastname@example.org"] )
smtp.gmail.com as we are going to be using Google Mail SMTP
Now that we know the structure of the SMTP notification block, it’s time to update our Monika configuration:
Save the configuration file as
monika.yml and run the configuration. When an alert is triggered, it should send a recovery or incident email to the recipients you have configured.
Congratulations! You can now send the alert notification using Google Mail SMTP!
PT Artha Rajamas Mandiri (Hyperjump) is an open-source-first company providing engineering excellence service. We aim to build and commercialize open-source tools to help companies streamline, simplify, and secure the most important aspects of its modern DevOps practices.
Copyright © 2024 Hyperjump Tech. All Rights Reserved.