ommysql: MariaDB/MySQL Database Output Module¶
Module Name: |
ommysql |
Author: |
Michael Meckelein (Initial Author) / Rainer Gerhards <rgerhards@adiscon.com> |
Purpose¶
This module provides native support for logging to MariaDB/MySQL databases. It offers superior performance over the more generic omlibdbi module.
Configuration Parameters¶
Note
Parameter names are case-insensitive; camelCase is recommended for readability.
Action Parameters¶
Parameter |
Summary |
|---|---|
Sets the MariaDB/MySQL server address the action connects to. |
|
Sets the Unix socket path to use when connecting to the MariaDB/MySQL server. |
|
Names the MariaDB/MySQL database that receives the log records. |
|
Defines the MariaDB/MySQL user account used for the connection. |
|
Specifies the password for the MariaDB/MySQL user defined in UID. |
|
Selects a non-standard port for the MariaDB/MySQL server connection. |
|
Selects an optional MariaDB/MySQL client configuration file (my.cnf) for the connection. |
|
Chooses the section within the client configuration file specified by MySQLConfig.File. |
|
Specifies the template used to format log records for insertion into the MariaDB/MySQL database. |
Failure and retry behavior¶
ommysql treats MariaDB/MySQL client and connection failures differently
from SQL data errors returned by the server.
Connection-level failures, such as an unavailable server or a broken
connection, suspend the action. In that state, the usual action retry settings,
including action.resumeInterval and action.resumeRetryCount, control
when rsyslog tries to resume delivery.
Server-side SQL errors, such as a rejected INSERT or stored procedure call,
are treated as permanent data failures for the affected messages. rsyslog logs
the MySQL error and the failed SQL statement, then handles the failed message
through the action error-file path. These failures are not retried (and thus not
throttled by action.resumeInterval) because retrying the same malformed
statement later would normally fail in the same way.
For production setups, configure action.errorfile on the ommysql action
when failed messages must be retained for inspection or replay. Without an error
file, permanently failed messages are discarded after rsyslog reports the action
failure.
Examples¶
Example 1¶
The following sample writes all syslog messages to the database “syslog_db” on mysqlserver.example.com. The server is being accessed under the account of “user” with password “pwd”.
module(load="ommysql")
action(type="ommysql" server="mysqlserver.example.com" serverPort="1234"
db="syslog_db" uid="user" pwd="pwd")
FAQ¶
Support: rsyslog Assistant | GitHub Discussions | GitHub Issues: rsyslog source project
Contributing: Source & docs: rsyslog source project
© 2008–2026 Rainer Gerhards and others. Licensed under the Apache License 2.0.