Integration von Drupal mit dem OhDear Überwachungsdienst!

08.09.2023,

⚠ Dieser Inhalt ist leider nicht auf Deutsch verfügbar.

Ohdear Features

What are the benefits that monitoring brings to your website?

A monitoring tool is a quality assurance tool that is the last line of defense against bugs and site issues. It monitors your production system and is also capable of monitoring your staging or test systems. No program is 100% perfect and from time to time bugs creep into the production system. If a sufficiently good monitoring system is in place, it will help catch those bugs, perhaps even before the readers find out about them. In any case, the motto here is, "the sooner, the better".

OhDear is a comprehensive monitoring service that keeps track of your website's uptime, SSL certificates, broken links, scheduled tasks and many other things. But the point where Oh Dear excels above other services is the wholesomeness of the product they offer. With very little effort, users get the website monitoring set up and the statistical data about performance and other critical aspects of their website is nicely presented. OhDear was created by Freek Van der Herten from Spatie, a renowned contributor in the Laravel ecosystem and Mattias Geniar from Nucleus. Learn more about the journey of Oh Dear! by visiting the launch story.

Issues can be received through a plethora of different notification systems such as chat services and other communication channels. So what would usually take days of configuration is in reach with a few clicks on Oh Dear dashboard. At drunomics we have recently introduced a weekly duty to frequently check our Oh Dear monitoring slack channel and jump on problems as soon as they emerge.

OhDear Integration with Drupal

In Drupal's ecosystem, there's a monitoring module already available (named simply Monitoring). It is not a monitoring solution by itself but it provides a lightweight sensor definition framework that can be collected by any monitoring product. It provided a nice starting point to base our OhDear Integration module on. Next part of the puzzle was the ohdear-php-sdk, a service development kit, PHP composer package that eases the connection with the Oh Dear's API. Oh Dear Integration module essentially acts as a bridge between Drupal's Monitoring module and Oh Dear. During the development of the module, the need for a new monitoring sensor became apparent. At drunomics we developed a new sensor that summarizes the Drupal's own requirements' system. With that newly developed sensor (we're still waiting on Monitoring module maintainer team to merge it into the main codebase) we can group together requirements' warnings and errors. Oh Dear then reads them together with other sensors' results on the special endpoint with JSON data and creates a health check report out of it.

The second functionality that OhDear Integration module brings is the Scheduled tasks monitoring. If configured, it will ping Oh Dear's endpoint at the end of the cron job and if the ping is received in specified time interval, Oh Dear will know that your cron is running on schedule. I've seen Drupal databases a few gigabytes larger than necessary simply because cron was not running and cache tables that are cleaned on cron runs were getting out of hand. This monitoring job would help debugging such issues.

The next piece of functionality that we added to the Oh Dear Integration module was the maintenance jobs drush command. With them, you can notify Oh Dear that your website is under maintenance and Oh Dear will go a bit easier on you with the error notifications and warnings. And because these are drush commands (for command line) we also use them in deployment scripts for our websites. That way we never get false positives on downtime reports and our downtime statistics remains in great shape. And we are not spammed with unnecessary notifications.

So, if you’re thinking about adding an all-in-one monitoring solution to your Drupal website, Oh Dear monitoring service together with Oh Dear integration module is probably one of the fastest and easiest ways to set it up. 

OhDear App

Signup for an Oh Dear account and add your site information. 

Configuration

Install OhDear Integration module with composer to your Drupal site and configure it. The process is well documented in the module's README file. The module provides /json/oh-dear-health-check-results endpoint for OhDear healthchecks. These are converted sensor results from Monitoring module. Endpoint requires configuraton of OhDear Healthcheck Secret that enables access of OhDear service to the endpoint. The Health Report Url /json/oh-dear-health-check-results should be added in OhDear App Application health settings.

Set the required values from the OhDear App at /admin/config/system/ohdear-settings

If you find a bug in the module or have an idea about a functionality that would improve OhDear Integration module, you can open an issue on the OhDear Intergration module page on drupal.org or write into our #drunomics-contribute Slack channel on Drupal Slack.

Happy monitoring!

P.S. Coming next to the OhDear Integration is the reverse connection between Oh Dear and the Drupal. So most valuable data from Oh Dear will also be available from inside of Drupal either via drush commands or on designated paths. There's an open issue on drupal.org that will bring the functionality to show results of Oh Dear checks, uptime and broken links to Drupal.