Skip to content

Commit

Permalink
[MySQL] Fix missing innodb metrics for MySQL 5.6 & 5.7 (#18904)
Browse files Browse the repository at this point in the history
* add mocked tests for innodb status parsing

* fix missing innodb metrics pending_log_writes, pending_checkpoint_writes, history_list_length

* add changelog

* remove print
  • Loading branch information
lu-zhengda authored Oct 23, 2024
1 parent 2b35698 commit 2cc0dcf
Show file tree
Hide file tree
Showing 20 changed files with 3,169 additions and 6 deletions.
5 changes: 5 additions & 0 deletions mysql/changelog.d/18904.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixes missing innodb metrics collected from `SHOW ENGINE INNODB STATUS` output.
- `mysql.innodb.history_list_length` for MySQL 5.6
- `mysq..innodb.pending_log_writes` for MySQL 5.7
- `mysql.innodb.pending_checkpoint_writes` for MySQL 5.7

12 changes: 12 additions & 0 deletions mysql/datadog_checks/mysql/innodb_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def get_stats_from_innodb_status(self, db):

# SEMAPHORES
if line.find('Mutex spin waits') == 0:
# MySQL 5.6 & 5.7 only
# Mutex spin waits 79626940, rounds 157459864, OS waits 698719
# Mutex spin waits 0, rounds 247280272495, OS waits 316513438
results['Innodb_mutex_spin_waits'] = int(row[3])
Expand Down Expand Up @@ -116,8 +117,13 @@ def get_stats_from_innodb_status(self, db):
# Trx id counter 861B144C
txn_seen = True
elif line.find('History list length') == 0:
# MySQL 5.7 and above
# History list length 132
results['Innodb_history_list_length'] = int(row[3])
elif line.find('idle History list length') == 0:
# MySQL 5.6 only
# idle History list length 123
results['Innodb_history_list_length'] += int(row[4])
elif txn_seen and line.find('---TRANSACTION') == 0:
# ---TRANSACTION 0, not started, process no 13510, OS thread id 1170446656
results['Innodb_current_transactions'] += 1
Expand Down Expand Up @@ -257,9 +263,15 @@ def get_stats_from_innodb_status(self, db):
# syncs, 2980893 checkpoints
results['Innodb_log_writes'] = int(row[0])
elif line.find(" pending log writes, ") > 0:
# MySQL 5.6 only
# 0 pending log writes, 0 pending chkp writes
results['Innodb_pending_log_writes'] = int(row[0])
results['Innodb_pending_checkpoint_writes'] = int(row[4])
elif line.find(" pending log flushes, ") > 0:
# MySQL 5.7 only
# 0 pending log flushes, 0 pending chkp writes
results['Innodb_pending_log_writes'] = int(row[0])
results['Innodb_pending_checkpoint_writes'] = int(row[4])
elif line.find("Log sequence number") == 0:
# This number is NOT printed in hex in InnoDB plugin.
# Log sequence number 272588624
Expand Down
12 changes: 6 additions & 6 deletions mysql/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ mysql.innodb.lsn_current,gauge,,,,Log sequence number as shown in the LOG sectio
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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
mysql.innodb.mutex_os_waits,gauge,,event,second,The rate of mutex OS waits.,0,mysql,mutex os waits,
mysql.innodb.mutex_spin_rounds,gauge,,event,second,The rate of mutex spin rounds.,0,mysql,mutex spin rounds,
mysql.innodb.mutex_spin_waits,gauge,,event,second,The rate of mutex spin waits.,0,mysql,mutex spin waits,
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,
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,
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,
mysql.innodb.os_file_fsyncs,gauge,,operation,,(Delta) The total number of fsync() operations performed by InnoDB.,0,mysql,mysql innodb os file fsyncs,
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,
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,
Expand All @@ -100,8 +100,8 @@ mysql.innodb.pending_aio_sync_ios,gauge,,,,As shown in the FILE I/O section of t
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,
mysql.innodb.pending_checkpoint_writes,gauge,,,,As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.,0,mysql,,
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,
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,
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,
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,
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,
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,
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,
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,
Expand Down
Loading

0 comments on commit 2cc0dcf

Please sign in to comment.