Monitor your MySQL database performance with comprehensive metrics collected by the NRDOT Collector. By default, New Relic collects the metrics and query-level events referenced in the Default metrics and events section. You can enhance your monitoring by enabling your desired metrics listed in the Full-feature metrics section.
Default metrics and events
The following metrics are collected automatically for New Relic UI functionality.
Metric | Description |
|---|---|
| Number of data pages in the InnoDB buffer pool. This metric has the following available attribute: |
| Configured size of the InnoDB buffer pool |
| Operations on the InnoDB buffer pool. This metric has the following available attribute: |
| Requests to flush pages from the InnoDB buffer pool |
| Number of pages in the InnoDB buffer pool. This metric has the following available attribute: |
| Bytes in the InnoDB buffer pool. This metric has the following available attribute: |
| Writes to the InnoDB doublewrite buffer. This metric has the following available attribute: |
| Requests to various MySQL handlers. This metric has the following available attribute: |
| I/O wait event count for an index. This metric has the following available attributes: |
| I/O wait event time for an index. This metric has the following available attributes: |
| Number of MySQL locks. This metric has the following available attribute: |
| InnoDB log operations. This metric has the following available attribute: |
| mysqlx connections (X Plugin / Document Store). This metric has the following available attribute: |
| Number of opened resources. This metric has the following available attribute: |
| InnoDB operations. This metric has the following available attribute: |
| InnoDB page operations. This metric has the following available attribute: |
| Prepared statement commands issued. This metric has the following available attribute: |
| InnoDB row locks. This metric has the following available attribute: |
| InnoDB row operations. This metric has the following available attribute: |
| Number of MySQL sorts. This metric has the following available attribute: |
| I/O wait event count for a table. This metric has the following available attributes: |
| I/O wait event time for a table. This metric has the following available attributes: |
| State of MySQL threads. This metric has the following available attribute: |
| Temporary resources created. This metric has the following available attribute: |
| Seconds the server has been up |
| Times each command type was executed. This metric has the following available attribute: |
| Statements executed by the server |
| Slow queries |
| Bytes read from or written to InnoDB data files |
Query events
The following events are collected as OpenTelemetry log records and are enabled by default. They provide query-level visibility.
Real-time visibility into currently-running database statements: a point-in-time snapshot taken every scrape, not a complete execution log. This event is enabled by default.
Use the query_sample_collection block to tune its behavior:
query_sample_collection: max_rows_per_query: 100 allowed_comment_keys: [nr_service_guid]Available parameters
Parameter | Description |
|---|---|
| The maximum number of rows to collect per scrape. The default value is set to |
| Keys to extract from leading SQL comments for APM-DB correlation |
Attributes collected
Attribute | Description |
|---|---|
|
|
| Unique identifier for the thread executing the statement |
|
|
| Foreground-thread user; empty for background threads |
| Thread's current database ( |
| Command type, or |
| Current action/state of the thread |
| SQL statement text |
| SHA-256 statement digest |
| Monotonic picosecond counter marking statement start: a stable per-execution key across scrape cycles |
| Elapsed execution time, in seconds |
| Elapsed wait time, in seconds (requires the |
| Top-level wait classification derived from the wait event name ( |
| Detailed wait breakdown: the wait event name with its category segment stripped (for example, |
| Raw, unprocessed name of the instrument that produced the wait event. For the parsed/categorized breakdown, see |
|
|
| Thread + current event number when the event started |
| Client host/port (port populated on MySQL 8.0.22+ only, else |
| Same, as network-layer attributes |
| JSON array of |
| Integer count of concurrent blockers. |
| Client driver's self-reported identity (for example, |
| APM-correlation comment tags: see (Optional) Set up APM-database correlation |
| MD5 of normalized SQL for cross-engine correlation |
Dica
Filter blocking with mysql.blocking.blocker.count > 0, not != 0. null != 0 evaluates TRUE in NRQL, which would silently include non-blocked sessions in your results.
The queries consuming the most execution time, aggregated server-side by MySQL's own performance_schema.events_statements_summary_by_digest: a true per-digest execution counter, not a sample count. This event is enabled by default.
Use the top_query_collection block to tune its behavior:
top_query_collection: lookback_time: 60 max_query_sample_count: 5000 top_query_count: 200 collection_interval: 60s query_plan_cache_size: 1000 query_plan_cache_ttl: 1h allowed_comment_keys: [nr_service_guid]Available parameters
Parameter | Description |
|---|---|
| The time window, in seconds, in which to query for top queries. Queries that finished execution outside the lookback window aren't included in the collection. Increasing this value helps capture long-running queries. The default value is 2 times the |
| The maximum number of records to fetch in a single run. The default value is set to |
| The maximum number of active queries to report in a single run. The default value is set to |
| The interval at which top queries are emitted by this receiver. The default value is set to |
| The size of the query plan cache used to store EXPLAIN results. The default value is set to |
| How long a cached query plan stays valid before the receiver re-runs EXPLAIN to refresh it. The default value is set to |
| Keys to extract from leading SQL comments for APM-DB correlation |
Attributes collected
Attribute | Description |
|---|---|
|
|
| SQL statement text (obfuscated) |
| Digest's |
| SHA-256 statement digest |
| Times the statement executed, reported as a per-scrape delta, not cumulative |
| Total execution time, delta seconds |
| Delta row counts. Dividing by |
| Same as |
| Same as |
Execution plan for a statement, reported as its own event so the plan can be filtered, routed, or dropped independently of top_query's/query_sample's own statistics. Requires at least one of db.server.top_query or db.server.query_sample to also be enabled. Once enabled, mysql.query_plan is no longer carried on db.server.top_query/db.server.query_sample records. See Execution plan collection for EXPLAIN mechanics. This event is enabled by default.
Attribute | Description |
|---|---|
|
|
| The default database/schema for the query. On query samples this is the thread's current database ( |
| Set to the same value as |
| The event the plan was reported for ( |
| The query plan for the statement, if available |
EXPLAIN needs a literal SQL statement: the normalized digest text uses placeholders (SELECT ? FROM t WHERE id = ?) that MySQL can't execute.
MySQL version | Plan availability |
|---|---|
| Available: |
| Not available: no |
If a captured statement is truncated (ends in ...), EXPLAIN is skipped on every version. See Recommended server parameters.
| Behavior |
|---|---|
| Runs |
| Routes through a |
Importante
mysql.query_plan is the raw EXPLAIN FORMAT=json output, wrapped in a one-element JSON array before caching, so New Relic's log ingest doesn't auto-flatten and destroy it. Parse index [0] to recover the plan object.
Full-feature metrics
The full-feature configuration collects every default metric plus the following additional metrics. These metrics are organized by functionality and most require a direct MySQL connection. You can set any of these metrics to true in the metrics section of your configuration to enable them.
Metric | Description |
|---|---|
| Connection attempts (successful or not) |
| Errors during the client connection process. This metric has the following available attribute: |
| Max simultaneous connections since server start |
| Bytes transmitted between server and clients. This metric has the following available attribute: |
| mysqlx worker threads available. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Statements sent to the server by clients only |
| Joins that perform table scans. This metric has the following available attribute: |
| Summary of current/recent statement events. This metric has the following available attributes: |
| Total wait time of summarized timed events. This metric has the following available attributes: |
Metric | Description |
|---|---|
| Average row length for a table. This metric has the following available attributes: |
| Row count for a table. This metric has the following available attributes: |
| Table size. This metric has the following available attributes: |
| Hits/misses/overflows for the open-tables cache. This metric has the following available attribute: |
| Table lock wait read events. This metric has the following available attributes: |
| Table lock wait read event time. This metric has the following available attributes: |
| Table lock wait write events. This metric has the following available attributes: |
| Table lock wait write event time. This metric has the following available attributes: |
Metric | Description |
|---|---|
| Seconds the replica must lag the source |
| How "late" the replica is |
| InnoDB page size |
Timer units
Telemetry type | Fields | Unit |
|---|---|---|
Log events ( |
| seconds |
Metrics (statement events, table/index I/O wait, table lock wait) | per | nanoseconds |
Importante
mysql.events_waits_current.timer_wait is the one field that is a genuine, distinct wait/block duration (not total elapsed time). Pair it with mysql.wait_event_type / mysql.wait_event (or the raw mysql.wait_type).
Attribute glossary
The following table describes every attribute referenced in the metric descriptions above. Attributes whose meaning depends on the metric they're attached to (such as kind, operation, status, and command) aren't listed here; their specific values are called out inline next to each metric instead.
Attribute | Description | Values |
|---|---|---|
| The schema of the object | Any string |
| Digest of the statement | Any string |
| Text before digestion | Any string |
| Table name for event or process | Any string |
| The name of the index | Any string |
| The kind of temporary resources |
|
| The connection error type |
|
Related documentation
Instrumentation in self-hosted environments
Learn how to set up MySQL monitoring in self-hosted environments with New Relic.
Instrumentation in RDS environments
Learn how to set up MySQL monitoring in RDS environments with New Relic.
Troubleshooting guide
Learn how to troubleshoot common issues with MySQL monitoring.