Monika uses a YAML file to define all the settings and configurations. You can find a sample configuration file in the repository called monika.example.yml.
Pro tips: If you use Visual Studio Code (VSCode) on a regular basis, you can write the configuration file with the help of auto completion by installing the YAML extension for VSCode. More information can be found in our Creating Monika Configuration from Scratch using Autocomplete in Visual Studio Code blog post.
Another pro tips: If you'd rather use a GUI to create the configuration file, you can use the Monika Config Generator web app.
In general Monika and its configuration file,
monika.yml is divided into three sections. A probe, an alert and a notification section.
Probes describe one or more requests to perform on your service to test. A probe will include the request, the URL to test, its method, timeout and any headers and body that you might wish to add.
Here is an example probe:
probes:- id: 'submission_test'name: HTML form submissiondescription: simulate html form submissioninterval: 10 # in secondsrequests:- url: https://httpbin.org/status/200method: POSTtimeout: 7000 # in millisecondsheaders:Content-Type: application/x-www-form-urlencoded
For further details on probes, check the Probes guide.
Alerts describe the conditions to trigger a notification. Alerts are basically test conditions for your service, such as http status, response time, or a particular response body.
The example below defines two alerts that will send notification if the HTTP response status is 500 or if the response time is greater than 150 ms.
alerts:- assertion: response.status == 500message: response status is 500- assertion: response.time > 150 # in millisecondsmessage: response time is slow
For details on alerts and how you can define different kind of queries, see the Alerts guide.
Once an alert is triggered, Monika will send one or more notifications through any of the supported channels that you defined.
For instance, a simple desktop notification needs to be defined as follows:
notifications:- id: my-desktop-notiftype: desktop
Or an e-mail notification via your own SMTP server can be done by defining the following configuration:
notifications:- id: random-string-smtptype: smtpdata:recipients: [RECIPIENT_EMAIL_ADDRESS]hostname: SMTP_HOSTNAMEport: 587username: SMTP_USERNAMEpassword: SMTP_PASSWORD
Note that you can define more than one notification and Monika will notify you through them all when an alert is triggered.
Monika supports a wide variety of communication channels such as WhatsApp, Discord, Google Chat, and many more. For the complete list of the different notification channels that Monika supports, visit the Notifications page.
Pro tips: If the communication app you are using with your team is not supported by Monika, you can follow our guide to add it to Monika in Add your choice of notification channels to Monika blog post. Some of the notification channels that Monika supports are thanks to fellow developers' open source contributions!
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 © 2023 Hyperjump Tech. All Rights Reserved.