Skip to content

Commit

Permalink
mariadb: allow enabling slow log (#3753)
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Mar 14, 2024
1 parent 0cfcc62 commit 05da265
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions modules/mariadb/manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Optional[Integer] $server_id = undef,
Boolean $enable_bin_logs = true,
Boolean $enable_ssl = true,
Boolean $enable_slow_log = false,
) {
$exporter_password = lookup('passwords::db::exporter')
$ido_db_user_password = lookup('passwords::icinga_ido')
Expand Down Expand Up @@ -119,6 +120,14 @@
use_udp => true,
}

if $enable_slow_log {
rsyslog::input::file { 'mysql-slow':
path => '/var/log/mysql/mysql-slow.log',
syslog_tag_prefix => '',
use_udp => true,
}
}

monitoring::services { 'MariaDB':
check_command => 'mysql',
docs => 'https://meta.miraheze.org/wiki/Tech:MariaDB',
Expand Down
14 changes: 11 additions & 3 deletions modules/mariadb/templates/config/mw.cnf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ join_cache_level = 8

performance_schema = off

log-error = /var/log/mysql/mysql-error.log
slow-query-log = 0
slow-query-log-file = /var/log/mysql/mysql-slow.log
log_output = FILE
log_error = /var/log/mysql/mysql-error.log
<%- if @enable_slow_log -%>
slow_query_log = ON
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 1
log_slow_admin_statements = ON
log_queries_not_using_indexes = OFF
<%- else -%>
slow_query_log = OFF
<%- end -%>

userstat = 1
plugin_load_add = query_response_time
Expand Down
2 changes: 2 additions & 0 deletions modules/role/manifests/db.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Optional[Array[String]] $fortnightly_misc = lookup('role::db::fornightly_misc', {'default_value' => []}),
Optional[Array[String]] $monthly_misc = lookup('role::db::monthly_misc', {'default_value' => []}),
Boolean $enable_bin_logs = lookup('role::db::enable_bin_logs', {'default_value' => true}),
Boolean $enable_slow_log = lookup('role::db::enable_slow_log', {'default_value' => false}),
Boolean $backup_sql = lookup('role::db::backup_sql', {'default_value' => true}),
Boolean $enable_ssl = lookup('role::db::enable_ssl', {'default_value' => true}),
) {
Expand Down Expand Up @@ -36,6 +37,7 @@
icinga_password => $icinga_password,
enable_bin_logs => $enable_bin_logs,
enable_ssl => $enable_ssl,
enable_slow_log => $enable_slow_log,
}

file { '/etc/mysql/miraheze/mediawiki-grants.sql':
Expand Down

0 comments on commit 05da265

Please sign in to comment.