Monitor your MariaDB or MySQL instances using Monika
Monika v1.14.0 was released on November 7th, 2022. This version includes the feature to monitor your MariaDB or MySQL instances using Monika configurations.
Of course, as a developer, we are familiar with MariaDB or MySQL. Both of them are SQL databases used for storing data. Using Monika, you can check if your MariaDB or MySQL instances are working by sending a simple query to check if it’s working or not.
This article will show you how to monitor your MariaDB or MySQL instances using Monika. So, without further ado:
Monitor your MariaDB or MySQL instances
Monika is an open-source and free synthetic monitoring command-line application. The name Monika stands for “Monitoring Berkala” in Bahasa Indonesia, which means “periodic monitoring”.
With Monika, you can add as many websites as you want to monitor. You can monitor several conditions such as service outages or slow services. Also, you can configure Monika to send notifications of the incidents on your services through your favorite communication tools like SMTP mail, WhatsApp (it’s free!), Microsoft Teams, Slack, and many more.
There are many ways to install Monika, from Node Package Manager (NPM), downloading binaries from the Monika release page, to package managers such as Homebrew or Snapcraft.
For demonstration purposes, let’s run a dockerized MariaDB and MySQL instance by running the following command:
# For running MariaDB
docker run -p 3307:3306 --detach --name some-mariadb -e MARIADB_USER=example-user -e MARIADB_PASSWORD=my_cool_secret -e MARIADB_ROOT_PASSWORD=my-secret-pw -e MARIADB_DATABASE=exampledb mariadb:latest# For running MySQL
docker run -p 3308:3306 --detach --name some-mysql -e MYSQL_USER=example-user -e MYSQL_PASSWORD=my_cool_secret -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=exampledb mysql:latest
Those commands will run MariaDB and MySQL instances: one in port 3307 for MariaDB, and the other in port 3308 for MySQL with username example-user and password my_cool_secret, along with a database exampledb in each instance.
Once we have our MariaDB and MySQL instances running, let’s create a Monika configuration:
In the configuration above, Monika will:
- Use the Desktop notification channel
- This configuration will monitor our MariaDB and MySQL instances using the credentials from the Docker commands.
- It will alert you if the DB is offline for two consecutive checks, and will alert you back if it has recovered.
With that said, let’s try our configuration by running monika -c monika.yml
in your terminal.
From the screenshot above we can see that Monika can connect to the databases. Next, let’s try to disable our instances by running docker stop some-mariadb
and docker stop some-mysql
in the other terminal window.
As you can see in the screenshot above, Monika notified us via Desktop notifications that our MariaDB and MySQL instances cannot be reached. Congratulations! You can now monitor your MariaDB and MySQL instances!
Closing
Aside from monitoring your endpoints, you should monitor all possible sources of incidents before it happens. So, what other native clients should we support after this? Drop your comments below!
If you’re having a problem with using Monika, don’t hesitate to create an issue on Monika’s Github Issue Page. If you like this article, don’t forget to clap and share this article with your friends!
That’s it for today, see you next time!
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 their modern DevOps practices.