This tutorial will show you how to integrate Monika with Mailgun so you can receive notifications from Monika straight to your email.
To get the Mailgun API Key, you need to create an account first. Head to https://www.mailgun.com and proceed to create an account. After that, log in to your dashboard.
After that, you need to configure your domain. Let’s assume that you are on the free tier. Click Sending, and click Domains. Then, click the first listed sandbox domain.
You will be redirected to a page that asks you “How would you like to send your emails from <YOUR_SANDBOX_DOMAIN>?”. On that page, select the API method and you will see your API key. Copy your API key and your sandbox domain and save it somewhere else.
Then, you need to add your email to the Authorized Recipients. On the same page, scroll down to see the Authorized Recipients section. Add your email for testing purposes, and verify your email.
Now that the preparation has been done, it’s time to run Monika with Mailgun notification.
Now that we have the Mailgun API Key, Sandbox Domain, set up the Authorized Recipients, and installed Monika, it’s time to create a configuration called monika.yml
:
notifications:- id: unique-id-mailguntype: mailgundata:recipients: ['YOUR_AUTHORIZED_RECIPIENTS_EMAIL']apiKey: YOUR_MAILGUN_API_KEYdomain: YOUR_SANDBOX_DOMAINprobes:- id: testinterval: 10requests:- url: https://reqres.in/api/usersmethod: GETalerts:- query: response.time > 2000message: Response time is longer than two seconds
Let me explain a little bit about this configuration:
notifications
object. There are 3 properties: id
, type
, and data
. Set the id
to any string values, as it is just an identifier. Then, set the type
field to mailgun
to use the Mailgun notification channel. After that, put your Mailgun API Key, recipients, and domain in the corresponding fields.Save the configuration as monika.yml. To run the Monika configuration, go to the directory where you saved the Monika configuration, and run Monika straight away using monika -c monika.yml
It’s working!
Congratulations! Now that you have successfully integrated Monika with Mailgun, you will be notified if your website is slow or down through your email!
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.