MySQL

The MySQL Integration allows you to ingest and monitor the performance and health metrics of your relational database management system (RDBMS) data. This integration is useful for identifying top SQL operations by row, tallying total requests to MySQL handlers, and tracking worker thread count.

There are two different methods for setting up the MySQL Integration. File-Baseed Authentication assumes you are a root MySQL user whereas User-Baseed Authentication allows you to connect the MySQL integration as a non-root user. Both installation methods will allow you to collect the same Metrics.

Prerequisites

Middleware Host Agent (MW Agent) must be installed on your local machine. To install the MW Agent, see our Installation Guide.

File-Based Authentication

Step 1: Create Database Credentials

Create a .yaml file containing database credentials like the below example. If the database is not password protected, the username and password fields can be removed.

For Docker users, create the credentials yaml file in the /var/log directory.

/home/ubuntu/mysql-creds.yaml

Step 2: Access Integrations

Log in to Middleware, navigate to the Installations Page in the bottom left corner, select All Integration and click MySQL

Step 3: Enable Integration

Add a host machine from the dropdown list, input the credential path from Step 1, and Save

User-Based Authentication

MySQL metrics are collected by querying performance_schema and sys_schema along with status variables that are managed by mysql-server. To allow for this collection you must create a non-root user with specific permissions described below.

Step 1: Create a User

Create a user named mw and specify your own unique password with the following command. mw will have the ability to login from any host unless otherwise specified.

To specify the specific host that mw can log into, change your above user name to the following: mw@'<hostaddr>'

Check if the user was created successfully by running the following command:

If successful, you will see the following output:

Step 2: Grant mw Permissions:

Grant mw permissions by running the following commands:

If you are using MariaDB you may need to grant additional permissions. Run the following command to grant the necessary permissions: GRANT slave monitor ON *.* TO 'mw'@'%';

Step 3: Check Permissions

Ensure you have properly granted permissions to the mw user by running the following commands:

Visualize Analytics

Default MySQL Dashboard

Once the MySQL integration setup is complete, a new MySQL-specific dashboard will appear in the Dashboard Builder. This default dashboard serves as a jumping off point for visualizing and analyzing MySQL data.

Create MySQL Widget

MySQL data can be added to dashboards as a custom widget. When adding a new widget, select the mysql data source to view a full list of available MySQL data.

Alerts

Alerts can be configured for any MySQL metrics. When creating a new rule select the Database detection method and MySQL database type for available metrics to appear in the Metrics dropdown list. Select the desired metric and continue configuring the alert conditions.

Metrics Collected

MetricDescription
mysql.buffer_pool.pagesNumber of pages in the InnoDB buffer pool
mysql.buffer_pool.data_pagesNumber of data pages in the InnoDB buffer pool
mysql.buffer_pool.page_flushesNumber of requests to flush pages from the InnoDB buffer pool
mysql.buffer_pool.operationsNumber of operations on the InnoDB buffer pool
mysql.buffer_pool.limitConfigured size of the InnoDB buffer pool
mysql.buffer_pool.usageNumber of bytes in the InnoDB buffer pool
mysql.commandsCount of commands executed, per command type
mysql.prepared_statementsCount of prepared statements executed, per statement type
mysql.handlersNumber of requests to MySQL handlers
mysql.double_writesNumber of writes to the InnoDB doublewrite buffer
mysql.log_operationsNumber of InnoDB log operations
mysql.operationsNumber of InnoDB operations
mysql.page_operationsNumber of InnoDB page operations
mysql.table.io.wait.countTotal count of I/O wait events for a table
mysql.table.io.wait.timeTotal time of I/O wait events for a table
mysql.index.io.wait.countTotal count of I/O wait events for an index
mysql.index.io.wait.timeTotal time of I/O wait events for an index
mysql.row_locksNumber of InnoDB row blocks
mysql.row_operationsNumber of InnoDB row operations
mysql.locksNumber of MySQL locks
mysql.sortsNumber of MySQL sorts
mysql.threadsState of MySQL threads
mysql.locked_connectsNumber of attempts to connect to locked user accounts
mysql.opened_resourcesNumber of opened resources
mysql.mysqlx_connectionsNumber of mysqlx connections
mysql.tmp_resourcesNumber of created temporary resources
mysql.table.lock_wait.read.countCount of lock wait read events
mysql.table.lock_wait.read.timeTotal lock wait read event time
mysql.table.lock_wait.write.countCount of lock wait write events
mysql.table.lock_wait.write.timeTotal lock wait write event time
mysql.locked_connectsNumber of attempts to connect to locked user accounts
mysql.connection.countTotal number of connection attempts to the MySQL server (includes successful and unsuccessful attempts)
mysql.connection.errorsClient connection process errors
mysql.mysqlx_connectionsNumber of mysqlx connections
mysql.joinsNumber of joins that perform table scans
mysql.replica.time_behind_sourceActual replica delay, in seconds
mysql.replica.sql_delayConfigured replica delay, in seconds
mysql.statement_event.countCount of statement events
mysql.statement_event.wait.timeTotal wait time of summarized timed events
mysql.mysqlx_worker_threadsNumber of worker threads available
mysql.table_open_cacheTotal number of hits, misses, and overflows for open table cache lookups
mysql.query.client.countNumber of client statements executed by the server
mysql.query.countTotal number of statements executed by the server
mysql.query.slow.countNumber of slow queries
mysql.statement_event.countSummary of current and recent statement events
mysql.statement_event.wait.timeThe total wait time of the summarized timed events
mysql.statement_event.count_starsThe total count of executed queries per normalized query and schema
mysql.innodb.buffer_pool_pages_flushedRate of pages being flushed from the InnoDB buffer pool
mysql.innodb.buffer_pool_read_requestsRate of read requests made to the InnoDB buffer pool
mysql.innodb.os_file_readsRate at which files are read by InnoDB
mysql.innodb.data_readRate at which data is read from disk by InnoDB
mysql.innodb.dblwr_pages_writtenRate of pages written to the doublewrite buffer to prevent partial page writes
mysql.innodb.ibuf_merged_delete_marksRate of delete marks merged from the insert buffer to the buffer pool
mysql.innodb.ibuf_merged_deletesRate of delete operations merged from the insert buffer
mysql.innodb.os_log_writtenTotal bytes written to the log by InnoDB
mysql.innodb.row_lock_waitsRate at which operations wait for row locks, indicative of contention on row-level data
mysql.innodb.buffer_pool_readsRate of read operations that required actual disk I/O in the InnoDB buffer pool
mysql.innodb.dblwr_writesRate of operations writing to the doublewrite buffer
mysql.innodb.s_lock_os_waitsRate at which OS waits for shared locks occur
mysql.innodb.s_lock_spin_waitsRate at which spin waits for shared locks occur
mysql.innodb.rows_deletedRate at which rows are being deleted in InnoDB
mysql.innodb.mutex_os_waitsRate at which InnoDB operations need to wait for operating system level mutexes
mysql.innodb.row_lock_timeTotal time spent waiting for row locks by operations in InnoDB
mysql.innodb.buffer_pool_wait_freeNumber of waits for a free page in the buffer pool
mysql.innodb.data_fsyncsRate of fsync operations by InnoDB to disk
mysql.innodb.lsn_flushedLog sequence number of the last flushed log
mysql.innodb.os_log_fsyncsRate at which fsync() operations are issued to the InnoDB log file
mysql.innodb.rows_insertedRate at which rows are being inserted in InnoDB
mysql.innodb.rows_readRate at which rows are being read in InnoDB
mysql.innodb.x_lock_os_waitsRate at which OS waits for exclusive locks occur
mysql.innodb.x_lock_spin_roundsRate at which spin rounds for exclusive locks occur
mysql.innodb.x_lock_spin_waitsRate at which spin waits for exclusive locks occur
mysql.innodb.pages_createdRate at which pages are created by InnoDB
mysql.innodb.data_readsRate of data read operations performed by InnoDB
mysql.innodb.ibuf_mergedRate at which records are merged from the insert buffer
mysql.innodb.ibuf_mergesRate of operations merging data from the insert buffer to the buffer pool
mysql.innodb.log_writesRate of actual log writes
mysql.innodb.os_file_fsyncsRate at which InnoDB performs fsync() operations on files
mysql.innodb.pages_readRate at which pages are read by InnoDB
mysql.innodb.s_lock_spin_roundsRate at which spin rounds for shared locks occur
mysql.innodb.buffer_pool_write_requestsRate of write requests to the InnoDB buffer pool
mysql.innodb.lsn_currentCurrent log sequence number
mysql.innodb.data_writesRate of data write operations performed by InnoDB
mysql.innodb.buffer_pool_read_aheadRate of pages read into the buffer pool by read-ahead
mysql.innodb.data_writtenRate at which data is written to disk by InnoDB
mysql.innodb.lsn_last_checkpointLog sequence number of the last checkpoint
mysql.innodb.mutex_spin_waitsRate of mutex spin waits in InnoDB, indicating contention within internal data structures
mysql.innodb.buffer_pool_read_ahead_evictedRate of pages read by read-ahead and then evicted without being accessed
mysql.innodb.ibuf_merged_insertsRate of insert operations merged from the insert buffer
mysql.innodb.os_file_writesRate at which files are written by InnoDB
mysql.innodb.mutex_spin_roundsRate of spin rounds per mutex spin in InnoDB, showing the effort needed to acquire a mutex
mysql.innodb.log_write_requestsNumber of write requests made to the log
mysql.innodb.pages_writtenRate at which pages are written by InnoDB
mysql.innodb.lock_structsRate at which lock structures are being used or created
mysql.innodb.log_waitsNumber of waits due to log buffer being too small
mysql.innodb.rows_updatedRate at which rows are being updated in InnoDB
mysql.innodb.mem_thread_hashMemory used by InnoDB for thread hash
mysql.innodb.locked_transactionsNumber of transactions that have acquired locks
mysql.innodb.mem_file_systemMemory used by InnoDB for file system data structures
mysql.innodb.buffer_pool_dataTotal number of bytes of data in the InnoDB buffer pool
mysql.innodb.pending_ibuf_aio_readsNumber of pending insert buffer asynchronous I/O reads
mysql.innodb.read_viewsNumber of 'read view' structures currently active; these are used to manage consistent read views
mysql.innodb.buffer_pool_pages_dirtyNumber of dirty pages in the InnoDB buffer pool
mysql.innodb.buffer_pool_totalTotal number of bytes within the InnoDB buffer pool
mysql.innodb.active_transactionsCurrent number of active transactions in InnoDB
mysql.innodb.data_pending_readsCurrent number of pending read operations in InnoDB
mysql.innodb.data_pending_writesCurrent number of pending write operations in InnoDB
mysql.innodb.pending_aio_sync_iosNumber of pending asynchronous I/O operations that need synchronization
mysql.innodb.buffer_pool_freeNumber of bytes currently free within the InnoDB buffer pool
mysql.innodb.os_log_pending_fsyncsNumber of pending fsyncs for logs
mysql.innodb.pending_normal_aio_readsNumber of pending normal asynchronous I/O read operations
mysql.innodb.row_lock_current_waitsCurrent number of operations waiting for row locks in InnoDB
mysql.innodb.ibuf_sizeTotal size of the insert buffer
mysql.innodb.mem_adaptive_hashMemory used by InnoDB for the adaptive hash index
mysql.innodb.buffer_pool_dirtyCurrent number of bytes held in dirty pages in the InnoDB buffer pool
mysql.innodb.buffer_pool_usedNumber of bytes currently used within the InnoDB buffer pool
mysql.innodb.locked_tablesNumber of tables currently locked by InnoDB
mysql.innodb.pending_aio_log_iosNumber of pending asynchronous I/O operations on the log
mysql.innodb.pending_normal_aio_writesNumber of pending normal asynchronous I/O write operations.
mysql.innodb.mem_page_hashMemory used by InnoDB for page hash
mysql.innodb.mem_lock_systemMemory used by InnoDB for lock system data structures
mysql.innodb.mem_totalTotal memory allocated to InnoDB
mysql.innodb.queries_queuedNumber of queries waiting to be processed by InnoDB
mysql.innodb.semaphore_waitsNumber of semaphore waits
mysql.innodb.buffer_pool_pages_dataNumber of data pages in the InnoDB buffer pool
mysql.innodb.buffer_pool_utilizationPercentage of the InnoDB buffer pool currently being utilized
mysql.innodb.hash_index_cells_totalTotal number of cells in the adaptive hash index
mysql.innodb.mem_additional_poolMemory allocated to InnoDB's additional pool
mysql.innodb.mem_dictionaryMemory used by InnoDB for dictionary information
mysql.innodb.pending_log_writesNumber of pending writes to the log file
mysql.innodb.queries_insideNumber of queries currently being processed inside InnoDB
mysql.innodb.tables_in_useNumber of tables currently in use by InnoDB
mysql.innodb.ibuf_segment_sizeSize of the segment available for the insert buffer
mysql.innodb.pending_checkpoint_writesNumber of pending writes to establish a new checkpoint
mysql.innodb.buffer_pool_read_ahead_rndNumber of random read-aheads in the InnoDB buffer pool
mysql.innodb.current_row_locksCurrent number of row locks held by operations in InnoDB
mysql.innodb.data_pending_fsyncsCurrent number of pending fsync operations in InnoDB
mysql.innodb.pending_buffer_pool_flushesNumber of pending buffer pool flush operations
mysql.innodb.current_transactionsCurrent number of transactions happening in InnoDB
mysql.innodb.semaphore_wait_timeTotal wait time for semaphores
mysql.innodb.history_list_lengthLength of the history list, indicating the number of pages consumed by transactions not yet flushed
mysql.innodb.ibuf_free_listNumber of pages in the insert buffer free list
mysql.innodb.mem_recovery_systemMemory used by InnoDB for transaction recovery
mysql.innodb.checkpoint_ageAge of the last checkpoint in InnoDB
mysql.innodb.hash_index_cells_usedNumber of used cells in the adaptive hash index
mysql.innodb.os_log_pending_writesNumber of pending log writes
mysql.innodb.buffer_pool_pages_freeNumber of free pages in the InnoDB buffer pool
mysql.innodb.pending_log_flushesNumber of pending flush operations for the log buffer
mysql.innodb.buffer_pool_pages_totalTotal number of pages in the InnoDB buffer pool

Troubleshooting

Missing Integrations Menu

If you do not see the Integrations Menu in Middlware, that means your account has not been granted Installation permissions. Contact your system administrator to add the Installation permission to your user role in Settings.

Next Steps

Need assistance or want to learn more about Middleware? Contact our support team in Slack.