Introducing the Monitoring Ntfy.sh Integration Module: Real-time Notifications for Drupal Monitoring

Image
The teaser image shows 2 example notifications of a monitoring incident

Empower your Drupal site with instant notifications using the Monitoring Ntfy.sh Integration module. My new module seamlessly integrates with Ntfy.sh, allowing you to receive real-time alerts and updates based on your Drupal site's monitoring results. Learn how to enhance your site's monitoring capabilities and stay informed with timely notifications in my blog post.

A short overview of the Monitoring Module

The great Monitoring module allows website admins to monitor vital internal parts of their Drupal website to detect unwanted changes as soon as possible. If offers great flexiblity by providing a lot of sensor plugins out-of-the box. 

Ever had a cron job failing for two weeks and noticed it too late? Or had a spam bot bypassing your form protection and left 1000 comments? The Monitoring module offers a dashboard with an overview of all sensors and can show you that.

The dashboard for the monitoring module showing multiple alerts like a alert for New Comments

Overview of Monitoring Ntfy.sh Integration Module

If you want to recieve a notification via email you could enable the experimental "Monitoring Mail" module. I wanted to have another way of getting notified about monitoring incidents and since I am using ntfy.sh for a while on my own instance I figured it would be a good idea to create a similar integration like the Monitoring Mail module but instead of sending an email I would like to sent a notification to a topic on my ntfy.sh instance.

The current version as of writing will send a notification for each configured severity-transition of a sensor (i.e. from OK to WARNING) to a specified topic. A later version of the module will allow granular configuration for each sensor if needed.

If you do not know what ntfy.sh is please check out the project here: https://ntfy.sh/. It is easy to use and you can use the default instance instead of setting up your own. 

How to install the monitoring_ntfy module

Note: This part could be outdated by the time you are reading this blog post. The blog post is from November 2023.

If you are using composer to maintain your website (like you should!) it is easy to install the module.

composer require 'drupal/monitoring_ntfy:^1.0@beta'

This will download the module and the library used to talk to ntfy.sh. After that enable it as usual, make sure to install and configure the Monitoring module before.

How to configure the monitoring_ntfy module

It is easy to configure the module. Head to /admin/config/system/monitoring/settings/ntfy and enter the nfty.sh server and topic where the notification messages will be sent to. Check all severities you would like to trigger a notification.

How to handle authentication

If you server requires authentication the modules supports Token Access and User/Password authentication. It is highly recommend to use environment variables instead of the configuration form but you can enter your details there if you would like to.

Please see the README.md in the module for more information about this.

Example configuration for the module

How to send the first notification

You can test if your notifications work by triggering a sensor. The easiest one would be the cron sensor which you can temporarily edit. Go to /admin/config/system/monitoring/sensors and edit the Last cron run age sensor. Under "Sensor tresholds" update the Warning and Critical fields by setting them to 1 and 60.

After saving the form run the Drupal cron and see if your notification appears. A WARNING message should show up in your channel. After 1 minute trigger it again, a CRITICAL message should show up.

Two example notifications for monitoring events

Conclusion

My new module hopefully offers a new way of using the Monitoring module for a lot of people. It is easy to install and use and is not invasive. Please try out the module and let me know if you have any questions or suggestions. Feel free to drop a comment here or use the issue queue!

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.