What it does
Log Alert Rules monitors Drupal's watchdog (dblog) entries and sends notifications when matches cross a configurable
threshold within a sliding time window. Each rule defines its own matching criteria, threshold, cooldown period, and
notification recipients.
What gap it fills
The dblog UI shows logs but cannot alert on patterns. Monolog contrib hands logs to external services but does not
natively threshold or cool down. ECA + custom models can approximate the behaviour but become unmaintainable as alert
cases grow. This module ships the threshold + cooldown + pluggable-channel combination as first-class config
entities.
Features
- Per-rule matching by log channel, severity, and message pattern (substring or regex), with an optional negate
pattern to exclude false positives. - Match against the raw message template or the fully rendered message with placeholders substituted.
- Configurable threshold count and sliding time window, plus a cooldown period that suppresses repeat
notifications. - Per-rule "Evaluate immediately" flag for high-priority alerts that should not wait for cron.
- Pluggable notification channel system; email ships in 1.0.x, additional channels can be added by implementing a
single interface. - Admin UI with drag-and-drop rule ordering, enable/disable, and a "Last fired" status display.
- Test action that scans recent dblog entries against a rule without sending a notification.
- YAML import/export for moving rules between sites, including bulk and per-rule exports.
- Self-logging: when a rule fires, it writes its own entry to a dedicated
log_alert_rules
channel.
Comments
Comment #2
vishal.kadamComment #3
avpadernoThank you for applying!
Before giving links helpful to understand how the review process works, what to expect from a review, and what to do to avoid a review takes more time than needed, I would like to thank all the reviewers for the work they do.
These applications are volunters-driven, which also means it is not possible to predict when an application will be marked fixed and the applicant will get the permission to opt projects into security advisory policy. While we aim to make an application as quick as possible, it is also important for us that more people review the project used for an application. In this way, we make sure applications do not miss some important points that should be instead reported.
Applications are not meant to be complete debugging sessions that eliminate every existing bug, though. I apologize if sometimes applications seem to go into too-detailed reviews.
Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.
The important notes are the following.
Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
To the reviewers
Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.
The important notes are the following.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.
Comment #4
vishal.kadamFILE: log_alert_rules.module
For a new module that aims to be compatible with Drupal 10 and Drupal 11, I would rather implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
Drupal does not have primary and secondary hooks. Instead of that, it is preferable to use the usual description: “Hook implementations for the [module name] module”, where [module name] is the name of the module given in its .info.yml file.
Comment #5
bdunphy commentedThank you @vishal.kadam. Modifications made to the code and tested. Now on RC4 for review.
Comment #6
avpadernomain is acceptable as branch name, but it is not yet fully supported on drupal.org.
With contributed projects, it is still not possible to create an issue for the main branch. For projects used in these applications, for which is still suggested to work with release-specific branches, it should be better to avoid using a branch with that name.
src/Controller/AlertRuleListBuilder.php
List builders are not controllers; their namespace should not contain Controller.
Drupal core started to retrieve controllers using PHP attributes; removing from the Controller directory classes that are not used for controllers is necessary to avoid Drupal looks for controllers in classes that are not controllers. See #3311365: Use PHP attributes for route discovery and #3584795: Remove non-controller classes from module Controller namespaces/folders for more information.
src/Controller/AlertRuleToggleController.php
Since that class does not use methods from the parent class, or it uses a single method from the parent class, it does not need to use
ControllerBaseas parent class.Controllers do not need to have a parent class; as long as they implement
\Drupal\Core\DependencyInjection\ContainerInjectionInterface, they are fine.With Drupal 10.3 and higher versions, a controller class does not need to implement
create(); usingAutowireTrait, it just needs to implement the class constructor.Documentation comments for methods and functions need to document parameters and return value.
src/Entity/AlertRule.php
Projects that are compatible with Drupal 10 or higher versions should use attributes instead of annotations. This means requiring at least Drupal 10.3, but this is not an issue, considering which Drupal core versions are nowadays supported.
Strings shown in the user interface must be translatable.
src/Form/AlertRuleImportForm.php
Since the class is
final, and cannot be extended, its properties can beprivateinstead ofprotected.The error message should make clear that the entered string contained just spaces, which is not the expected value.
For translatable strings that change basing on a number (as in this case), there is
::formatPlural().LICENSE.txt
The content of the LICENSE.txt file is expected to be the same of the LICENSE.txt file used by Drupal core.
composer.json
The Drupal.org Composer Façade automatically adds the core requirements for the project basing on what entered in the .info.yml file. As noted in Add a composer.json file:
This point is not suggesting a change is necessary; its purpose is to make sure you know what the Drupal.org Composer façade does, and that, when adding core requirements also in the composer.json file, it is necessary to double check they are compatible with the core requirements in the .info.yml file.
I cannot think of any workflow where Composer is not used to gather the projects necessary for a site, and their dependencies, considering that Composer is required by Drupal core to gather its dependencies, but that does not mean that having the core requirements also in the composer.json file is not necessary in specific cases.
log_alert_rules.module
A new module that aims to be compatible with latest Drupal releases is expected to implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
It requires increasing the minimum required Drupal version, but that is not an issue, since not all the Drupal releases are supported.
log_alert_rules.services.yml
Services can be autowired starting with Drupal 9.3.x. This means that it is no longer necessary to give a list of service arguments in the .services.yml file; they will be retrieved from the constructor definition.
Comment #7
bdunphy commentedI took to heart the comments. Log Alert Rules was a project I started last year and picked back up again this year to finish off. It's clear that I needed to spend more time looking at the standards docs. Comments here have been addressed and RC8 is ready for review. Thank you.
Comment #8
bdunphy commentedNeglected to change the status and doing so with this comment.
Comment #9
bdunphy commentedWhile waiting for review, found and fixed a bug and added more tests. Now on RC9.