MySQL (remote monitoring) extension

  • Latest Dynatrace
  • Extension
  • Published Oct 27, 2025

Monitor your MySQL instances remotely, collect key KPIs, and slow query details.

Overview dashboardInstance statistics on the new platformSlow queries viewExecution plan details
1 of 4Overview dashboard

Get started

Overview

Remotely monitor MySQL databases where you can't install OneAgent.

Compatibility information

MySQL version 8.0 or higher is required.

Activation and setup

  1. Activate the extension in the Hub by going to Extensions > MySQL > Add to environment.
  2. Add a new monitoring configuration for every MySQL instance you'd like to monitor.

Create MySQL user

  1. Create a user that is identified by a native password, and customize the username and password.

    CREATE USER 'dynatrace'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
  2. Give the user the following permissions:

    • GRANT SELECT ON performance_schema.* TO 'dynatrace'@'%';
      • Allows the user to query the performance_schema schema
    • GRANT PROCESS ON *.* TO 'dynatrace'@'%';
      • Allows the user to see thread and connection metrics for other users
    • GRANT SHOW DATABASES ON *.* TO 'dynatrace'@'%';
      • Allows the user to see database metrics for all databases
    • GRANT SELECT ON mysql.slow_log TO 'dynatrace'@'%';
      • Allows the user to query slow queries
    • GRANT SELECT ON sys.x$memory_global_by_current_bytes TO 'dynatrace'@'%';
      • Allow the user to query memory statistics

Due to a MySQL limitation, to calculate database sizes, you need to grant SELECT permissions on the individual databases from which you want to collect the size.

Collect infrastructure metrics

To enable CPU metrics collection, run this query in the MySQL instance:

SET GLOBAL innodb_monitor_enable='cpu%';

Collect Top Slow Queries

The following steps apply to the slow_queries feature set which retrieves data from mysql.slow_log.

This approach will be deprecated in a future release.

  1. Enable slow queries logging to a table:

    SET GLOBAL log_output = 'TABLE';
    SET GLOBAL slow_query_log = 'ON';

    The default slow query threshold is 10 seconds.

  2. Optionally, choose the threshold of what is a "slow query" by executing:

    SET GLOBAL long_query_time = 2;

    This sets the slow queries threshold to 2 seconds.

The following steps apply to the top_queries feature set which retrieves data from performance_schema.events_statements_summary_by_digest.

  1. Enable the necessary statement instruments, which tells MySQL to track all statements:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = 'YES', TIMED = 'YES'
    WHERE NAME LIKE 'statement/%';
  2. Enable the consumers, which tells MySQL where to store the tracked statements:

    UPDATE performance_schema.setup_consumers
    SET ENABLED = 'YES'
    WHERE NAME IN ('events_statements_history', 'events_statements_summary_by_digest');
    Note for AWS Relational Database Service (RDS)

    The recommended way to enable this on RDS is to create a custom parameter group. In the group, set performance_schema to 1 and enable the required consumer settings. This configuration persists across restarts and instance changes. For more details, see Turn on the Performance Schema for Amazon RDS for MariaDB or MySQL.

Fetch execution plans

To fetch execution plans:

  1. Create a stored procedure for the dynatrace user:

    CREATE SCHEMA IF NOT EXISTS dynatrace;
    DELIMITER $$
    CREATE PROCEDURE dynatrace.dynatrace_execution_plan(IN query TEXT)
    SQL SECURITY DEFINER
    BEGIN
    SET @explain := CONCAT('EXPLAIN FORMAT=JSON ', query);
    PREPARE stmt FROM @explain;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
    END $$
    DELIMITER ;
  2. Grant execution permission for the dynatrace user:

    GRANT EXECUTE ON PROCEDURE dynatrace.dynatrace_execution_plan TO 'dynatrace'@'%';

FAQ

Data collection must be allowed for the MySQL instance to gather wait metrics. For more details, see Performance Schema Wait Event Tables.

This extension was tested only with MySQL instances. MariaDB is not officially supported.

This error means the username is not identified by a native password. For more details, see the Get started section.

Ensure that data collection is enabled for your instance.

To test that you can query the data, run:

SELECT * FROM information_schema.INNODB_METRICS WHERE name IN ('cpu_utime_pct', 'cpu_stime_pct');

And:

SELECT SUBSTRING_INDEX(event_name,'/',2) AS code_area,
SUM(current_alloc) AS current_alloc
FROM sys.x$memory_global_by_current_bytes
GROUP BY SUBSTRING_INDEX(event_name,'/',2)
ORDER BY SUM(current_alloc) DESC;

On Managed tenants, log records can be retrieved by filtering logs using 2 attributes:

  • dt.extension.name: com.dynatrace.extension.mysql
  • event.group: top_queries (versions 2.1.6+) or event.group: query_performance (versions <2.1.6)

Feature sets

When activating your extension using monitoring configuration, you can limit monitoring to one of the feature sets. To work properly the extension has to collect at least one metric after the activation.

In highly segmented networks, feature sets can reflect the segments of your environment. Then, when you create a monitoring configuration, you can select a feature set and a corresponding ActiveGate group that can connect to this particular segment.

All metrics that aren't categorized into any feature set are considered to be the default and are always reported.

A metric inherits the feature set of a subgroup, which in turn inherits the feature set of a group. Also, the feature set defined on the metric level overrides the feature set defined on the subgroup level, which in turn overrides the feature set defined on the group level.

Metric nameMetric keyDescription
Queriesmysql.global_status.queries.countThe total number of queries executed by the server. This includes statements executed within stored procedures, unlike the Questions variable.
Slow Queriesmysql.global_status.slow_queries.countThe number of queries that have taken more than long_query_time seconds. This counter increments regardless of whether the slow query log is enabled. For information about that log, see Section 5.4.5, The Slow Query Log.
Table Locks Waitedmysql.global_status.table_locks_waited.countThe number of times that a request for a table lock could not be granted immediately and a wait was needed. If this is high and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.
Table Locks Immediatemysql.global_status.table_locks_immediate.countThe number of times that a request for a table lock could be granted immediately.
Current Connectionsmysql.global_status.current_connectionsThe number of currently open connections.
Threads Runningmysql.global_status.threads_runningThe number of threads that are not sleeping.
Innodb Buffer Pool Pages Datamysql.global_status.innodb_buffer_pool_pages_dataThe number of pages in the InnoDB buffer pool containing data. The number includes both dirty and clean pages. When using compressed tables, the reported Innodb_buffer_pool_pages_data value may be larger than Innodb_buffer_pool_pages_total
Innodb Buffer Pool Pages Dirtymysql.global_status.innodb_buffer_pool_pages_dirtyThe current number of dirty pages in the InnoDB buffer pool.
Innodb Buffer Pool Pages Freemysql.global_status.innodb_buffer_pool_pages_freeThe number of free pages in the InnoDB buffer pool.
Innodb Buffer Pool Pages Totalmysql.global_status.innodb_buffer_pool_pages_totalThe total size of the InnoDB buffer pool, in pages. When using compressed tables, the reported Innodb_buffer_pool_pages_data value may be larger than Innodb_buffer_pool_pages_total
Innodb Data Readsmysql.global_status.innodb_data_reads.countThe total number of data reads (OS file reads).
Innodb Data Writesmysql.global_status.innodb_data_writes.countThe total number of data writes.
Innodb Data Readmysql.global_status.innodb_data_read.countThe total amount of data read from files.
Innodb Data Writtenmysql.global_status.innodb_data_written.countThe total amount of data written.
Innodb Buffer Pool Readsmysql.global_status.innodb_buffer_pool_readsThe number of logical reads that InnoDB could not satisfy from the buffer pool, and had to read directly from disk.
Innodb Buffer Pool Read Requestsmysql.global_status.innodb_buffer_pool_read_requestsThe number of logical read requests.
Availabilitymysql.global_status.availabilityWhether or not a connection can be made to the database
Statusmysql.global_status.statusA status of AVAILABLE is returned if we can query the database
Uptimemysql.global_status.uptimeThe time in seconds that the MySQL server has been running since it was started.
Metric nameMetric keyDescription
CPU Usermysql.infrastructure.cpu.userThe percentage of CPU time spent in user mode.
CPU Systemmysql.infrastructure.cpu.systemThe percentage of CPU time spent in system mode.
Memorymysql.infrastructure.memoryThe amount of memory used per each code area.
Metric nameMetric keyDescription
Metric nameMetric keyDescription
Database Sizemysql.databases.sizeThe size of the Database
Metric nameMetric keyDescription
Commitsmysql.statements.commit.countThe number of COMMIT statements executed by this server
Deletesmysql.statements.delete.countThe number of DELETE statements executed by this server
Multi-Table Deletesmysql.statements.delete_multi.countThe number of multi-table DELETE statements executed by this server
Insertsmysql.statements.insert.countThe number of INSERT statements executed by this server
Selectsmysql.statements.select.countThe number of SELECT statements executed by this server
Updatesmysql.statements.update.countThe number of UPDATE statements executed by this server
Executesmysql.statements.execute.countThe number of EXECUTE statements executed by this server
Multi-Table Updatesmysql.statements.update_multi.countThe number of multi-table UPDATE statements executed by this server
Bytes Sentmysql.statements.bytes_sent.countThe number of bytes sent to all clients
Bytes Receivedmysql.statements.bytes_received.countThe number of bytes received from all clients
Metric nameMetric keyDescription
Metric nameMetric keyDescription
Waits IOmysql.waits.waits_io.countThe number of times that the server has waited for an I/O operation to complete.
Waits IO Timemysql.waits.waits_io_time.countThe total time the server has waited for I/O operations to complete.
Waits Syncmysql.waits.waits_sync.countThe number of times that the server has waited for a synchronization operation to complete.
Waits Sync Timemysql.waits.waits_sync_time.countThe total time the server has waited for synchronization operations to complete.
Related tags
DatabaseSQLMySQLMySQLApplication Observability