[MXS-2959] Allow "alert" script to be executed when errors or warnings are logged Created: 2020-04-10  Updated: 2023-10-04  Resolved: 2023-10-04

Status: Closed
Project: MariaDB MaxScale
Component/s: N/A
Affects Version/s: None
Fix Version/s: N/A

Type: New Feature Priority: Major
Reporter: Chris Calender (Inactive) Assignee: Todd Stoffel (Inactive)
Resolution: Won't Do Votes: 0
Labels: None

Issue Links:
Relates

 Description   

It would be a very useful feature if MaxScale could allow an "alert" script to be executed anytime errors or warnings are logged.

The more granular this would be, the better (perhaps it could be a comma-delimited list of error/warning code values).

To give an example, someone wants to be able to be notified immediately, via a script from MaxScale, when they see the following error ("Too many connections"):

2020-04-01 10:00:01 error : Unable to write to backend 'server1' due to authentication failure. Server in state RUNNING SLAVE.
2020-04-01 10:00:01 error : (661327) Invalid authentication message from backend 'server1'. Error code: 1040, Msg : #08004Too many connections



 Comments   
Comment by Johan Wikman [ 2020-04-14 ]

Perhaps this could be handled by this functionality:
https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-maxscale-configuration-guide/#events

So the basic principle is that you can define the syslog facility and level that should be used when certain events are logged. If you use another facility than the one used by default, you will be able to easily pick these out from the syslog message stream.

The underlying mechanism is generic, so if you can clearly define a particular event, it's possible to add support for it.

Comment by markus makela [ 2022-07-18 ]

Using the streaming log API that already exists in MaxScale to implement it elsewhere should be pretty easy. Since it's a WebSocket, a simple Node.JS script could work:

const ws = require("ws");
const sock = new ws.WebSocket("ws://localhost:8989/v1/maxscale/logs/stream", {auth: "admin:mariadb"});
 
sock.on('message', function message(data) {
    /* Add your logic here to determine what to do with the log message */
    let js = JSON.parse(data);
    console.log(js);
});

Generated at Thu Feb 08 04:17:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.