Skip to content

Commit 2cc0dcf

Browse files
authored
[MySQL] Fix missing innodb metrics for MySQL 5.6 & 5.7 (#18904)
* add mocked tests for innodb status parsing * fix missing innodb metrics pending_log_writes, pending_checkpoint_writes, history_list_length * add changelog * remove print
1 parent 2b35698 commit 2cc0dcf

20 files changed

+3169
-6
lines changed

mysql/changelog.d/18904.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fixes missing innodb metrics collected from `SHOW ENGINE INNODB STATUS` output.
2+
- `mysql.innodb.history_list_length` for MySQL 5.6
3+
- `mysq..innodb.pending_log_writes` for MySQL 5.7
4+
- `mysql.innodb.pending_checkpoint_writes` for MySQL 5.7
5+

mysql/datadog_checks/mysql/innodb_metrics.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def get_stats_from_innodb_status(self, db):
7979

8080
# SEMAPHORES
8181
if line.find('Mutex spin waits') == 0:
82+
# MySQL 5.6 & 5.7 only
8283
# Mutex spin waits 79626940, rounds 157459864, OS waits 698719
8384
# Mutex spin waits 0, rounds 247280272495, OS waits 316513438
8485
results['Innodb_mutex_spin_waits'] = int(row[3])
@@ -116,8 +117,13 @@ def get_stats_from_innodb_status(self, db):
116117
# Trx id counter 861B144C
117118
txn_seen = True
118119
elif line.find('History list length') == 0:
120+
# MySQL 5.7 and above
119121
# History list length 132
120122
results['Innodb_history_list_length'] = int(row[3])
123+
elif line.find('idle History list length') == 0:
124+
# MySQL 5.6 only
125+
# idle History list length 123
126+
results['Innodb_history_list_length'] += int(row[4])
121127
elif txn_seen and line.find('---TRANSACTION') == 0:
122128
# ---TRANSACTION 0, not started, process no 13510, OS thread id 1170446656
123129
results['Innodb_current_transactions'] += 1
@@ -257,9 +263,15 @@ def get_stats_from_innodb_status(self, db):
257263
# syncs, 2980893 checkpoints
258264
results['Innodb_log_writes'] = int(row[0])
259265
elif line.find(" pending log writes, ") > 0:
266+
# MySQL 5.6 only
260267
# 0 pending log writes, 0 pending chkp writes
261268
results['Innodb_pending_log_writes'] = int(row[0])
262269
results['Innodb_pending_checkpoint_writes'] = int(row[4])
270+
elif line.find(" pending log flushes, ") > 0:
271+
# MySQL 5.7 only
272+
# 0 pending log flushes, 0 pending chkp writes
273+
results['Innodb_pending_log_writes'] = int(row[0])
274+
results['Innodb_pending_checkpoint_writes'] = int(row[4])
263275
elif line.find("Log sequence number") == 0:
264276
# This number is NOT printed in hex in InnoDB plugin.
265277
# Log sequence number 272588624

mysql/metadata.csv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ mysql.innodb.lsn_current,gauge,,,,Log sequence number as shown in the LOG sectio
7575
mysql.innodb.lsn_flushed,gauge,,,,Flushed up to log sequence number as shown in the LOG section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb lsn_flushed,
7676
mysql.innodb.lsn_last_checkpoint,gauge,,,,Log sequence number last checkpoint as shown in the LOG section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb lsn_last_checkpoint,
7777
mysql.innodb.mem_adaptive_hash,gauge,,byte,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem_adaptive_hash,
78-
mysql.innodb.mem_additional_pool,gauge,,byte,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem_additional_total,
78+
mysql.innodb.mem_additional_pool,gauge,,byte,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output. Only available in MySQL 5.6.,0,mysql,mysql innodb mem_additional_total,
7979
mysql.innodb.mem_dictionary,gauge,,byte,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem_dictionary,
8080
mysql.innodb.mem_file_system,gauge,,,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem filesystem,
8181
mysql.innodb.mem_lock_system,gauge,,,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem locksystem,
8282
mysql.innodb.mem_page_hash,gauge,,,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem page hash,
8383
mysql.innodb.mem_recovery_system,gauge,,,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem recovery system,
8484
mysql.innodb.mem_total,gauge,,byte,,As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb mem_total,memory
85-
mysql.innodb.mutex_os_waits,gauge,,event,second,The rate of mutex OS waits.,0,mysql,mutex os waits,
86-
mysql.innodb.mutex_spin_rounds,gauge,,event,second,The rate of mutex spin rounds.,0,mysql,mutex spin rounds,
87-
mysql.innodb.mutex_spin_waits,gauge,,event,second,The rate of mutex spin waits.,0,mysql,mutex spin waits,
85+
mysql.innodb.mutex_os_waits,gauge,,event,second,The rate of mutex OS waits. Only available in MySQL 5.6 and 5.7.,0,mysql,mysql innodb mutex os waits,
86+
mysql.innodb.mutex_spin_rounds,gauge,,event,second,The rate of mutex spin rounds. Only available in MySQL 5.6 and 5.7.,0,mysql,mutex spin rounds,
87+
mysql.innodb.mutex_spin_waits,gauge,,event,second,The rate of mutex spin waits. Only available in MySQL 5.6 and 5.7.,0,mysql,mutex spin waits,
8888
mysql.innodb.os_file_fsyncs,gauge,,operation,,(Delta) The total number of fsync() operations performed by InnoDB.,0,mysql,mysql innodb os file fsyncs,
8989
mysql.innodb.os_file_reads,gauge,,operation,,(Delta) The total number of files reads performed by read threads within InnoDB.,0,mysql,mysql innodb os file reads,
9090
mysql.innodb.os_file_writes,gauge,,operation,,(Delta) The total number of file writes performed by write threads within InnoDB.,0,mysql,mysql innodb os file writes,
@@ -100,8 +100,8 @@ mysql.innodb.pending_aio_sync_ios,gauge,,,,As shown in the FILE I/O section of t
100100
mysql.innodb.pending_buffer_pool_flushes,gauge,,flush,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb buffer flushes,
101101
mysql.innodb.pending_checkpoint_writes,gauge,,,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,,
102102
mysql.innodb.pending_ibuf_aio_reads,gauge,,,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb aio reads,
103-
mysql.innodb.pending_log_flushes,gauge,,flush,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb log flush,
104-
mysql.innodb.pending_log_writes,gauge,,write,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb log write,
103+
mysql.innodb.pending_log_flushes,gauge,,flush,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output. Only available in MySQL 5.6 and 5.7.,0,mysql,mysql innodb log flush,
104+
mysql.innodb.pending_log_writes,gauge,,write,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output. Only available in MySQL 5.6 and 5.7.,0,mysql,mysql innodb log write,
105105
mysql.innodb.pending_normal_aio_reads,gauge,,read,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb aio read,
106106
mysql.innodb.pending_normal_aio_writes,gauge,,write,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql aio write,
107107
mysql.innodb.queries_inside,gauge,,query,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,mysql innodb queries inside,

0 commit comments

Comments
 (0)