MySQL
MySQL metrics collection, which collects the following data:
- MySQL global status basic data collection
- Schema related data
- InnoDB related metrics
- Support custom query data collection
Configuration¶
Preconditions¶
- MySQL version 5.7+
- Create a monitoring account (in general, you need to log in with MySQL
root
account to create MySQL users)
CREATE USER 'datakit'@'localhost' IDENTIFIED BY '<UNIQUEPASSWORD>';
-- MySQL 8.0+ create the datakit user with the caching_sha2_password method
CREATE USER 'datakit'@'localhost' IDENTIFIED WITH caching_sha2_password by '<UNIQUEPASSWORD>';
- Authorization
GRANT PROCESS ON *.* TO 'datakit'@'localhost';
GRANT SELECT ON *.* TO 'datakit'@'localhost';
show databases like 'performance_schema';
GRANT SELECT ON performance_schema.* TO 'datakit'@'localhost';
GRANT SELECT ON mysql.user TO 'datakit'@'localhost';
GRANT replication client on *.* to 'datakit'@'localhost';
Note
- All the above creation and authorization operations limit that the user
datakit
can only access MySQL on MySQL host (localhost
). If MySQL is collected remotely, it is recommended to replacelocalhost
with%
(indicating that DataKit can access MySQL on any machine), or use a specific DataKit installation machine address. -
Note that if you find the collector has the following error when using
localhost
, you need to replace the abovelocalhost
with::1
:
Collector Configuration¶
Go to the conf.d/db
directory under the DataKit installation directory, copy mysql.conf.sample
and name it mysql.conf
. Examples are as follows:
[[inputs.mysql]]
host = "localhost"
user = "datakit"
pass = "<PASS>"
port = 3306
# sock = "<SOCK>"
# charset = "utf8"
## @param connect_timeout - number - optional - default: 10s
# connect_timeout = "10s"
## Deprecated
# service = "<SERVICE>"
interval = "10s"
## @param inno_db
innodb = true
## table_schema
tables = []
## user
users = []
## Set replication to true to collect replication metrics
# replication = false
## Set group_replication to true to collect group replication metrics
# group_replication = false
## Set dbm to true to collect database activity
# dbm = false
## Set true to enable election
election = true
## Metric name in metric_exclude_list will not be collected, such as ["mysql_schema", "mysql_user_status"]
metric_exclude_list = [""]
## collect mysql object
[inputs.mysql.object]
## Set true to enable mysql object collection
enabled = true
## interval to collect mysql object which will be greater than collection interval
interval = "600s"
[inputs.mysql.log]
# #required, glob logfiles
# files = ["/var/log/mysql/*.log"]
## glob filteer
# ignore = [""]
## optional encodings:
## "utf-8", "utf-16le", "utf-16le", "gbk", "gb18030" or ""
# character_encoding = ""
## The pattern should be a regexp. Note the use of '''this regexp'''
## regexp link: https://golang.org/pkg/regexp/syntax/#hdr-Syntax
multiline_match = '''^(# Time|\d{4}-\d{2}-\d{2}|\d{6}\s+\d{2}:\d{2}:\d{2}).*'''
## grok pipeline script path
pipeline = "mysql.p"
## Run a custom SQL query and collect corresponding metrics.
# [[inputs.mysql.custom_queries]]
# sql = '''
# select ENGINE as engine,TABLE_SCHEMA as table_schema,count(*) as table_count
# from information_schema.tables
# group by engine,table_schema
# '''
# metric = "mysql_custom"
# tags = ["engine", "table_schema"]
# fields = ["table_count"]
# interval = "10s"
## Config dbm metric
[inputs.mysql.dbm_metric]
enabled = true
## Config dbm sample
[inputs.mysql.dbm_sample]
enabled = true
## Config dbm activity
[inputs.mysql.dbm_activity]
enabled = true
## TLS Config
# [inputs.mysql.tls]
# tls_ca = "/etc/mysql/ca.pem"
# tls_cert = "/etc/mysql/cert.pem"
# tls_key = "/etc/mysql/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = true
## by default, support TLS 1.2 and above.
## set to true if server side uses TLS 1.0 or TLS 1.1
# allow_tls10 = false
[inputs.mysql.tags]
# some_tag = "some_value"
# more_tag = "some_other_value"
Once configured, restart DataKit.
The collector can now be turned on by ConfigMap Injection Collector Configuration.
Binlog Start¶
MySQL Binlog is not turned on. If you want to count the Binlog size, you need to turn on the Binlog function corresponding to MySQL:
Binlog starts, see this or this answer.
Database Performance Metrics Collection¶
The database performance metrics come from MySQL's built-in database performance_schema
, which provides a way to get the internal performance of the server at runtime. Through this database, DataKit can collect statistics of various metrics of historical query statements, execution plans of query statements and other related performance metrics. The collected performance metric data is saved as a log, and the sources are mysql_dbm_metric
, mysql_dbm_sample
and mysql_dbm_activity
.
To turn it on, you need to perform the following steps.
- Modify the configuration file and start monitoring and collection
[[inputs.mysql]]
# Turn on database performance metric collection
dbm = true
...
# Monitor metric configuration
[inputs.mysql.dbm_metric]
enabled = true
# Monitor sampling configuration
[inputs.mysql.dbm_sample]
enabled = true
# Waiting for event collection
[inputs.mysql.dbm_activity]
enabled = true
...
- MySQL Configuration
Modify the configuration file (such as mysql.conf
), open the MySQL Performance Schema
, and configure the parameters:
[mysqld]
performance_schema = on
max_digest_length = 4096
performance_schema_max_digest_length = 4096
performance_schema_max_sql_text_length = 4096
performance-schema-consumer-events-statements-current = on
performance-schema-consumer-events-waits-current = on
performance-schema-consumer-events-statements-history-long = on
performance-schema-consumer-events-statements-history = on
- Account configuration
Account authorization
-- MySQL 5.6 & 5.7
GRANT REPLICATION CLIENT ON *.* TO datakit@'%' WITH MAX_USER_CONNECTIONS 5;
GRANT PROCESS ON *.* TO datakit@'%';
-- MySQL >= 8.0
ALTER USER datakit@'%' WITH MAX_USER_CONNECTIONS 5;
GRANT REPLICATION CLIENT ON *.* TO datakit@'%';
GRANT PROCESS ON *.* TO datakit@'%';
Create a database
CREATE SCHEMA IF NOT EXISTS datakit;
GRANT EXECUTE ON datakit.* to datakit@'%';
GRANT CREATE TEMPORARY TABLES ON datakit.* TO datakit@'%';
Create the stored procedure explain_statement
to get the SQL execution plan
DELIMITER $$
CREATE PROCEDURE datakit.explain_statement(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 ;
Create a separate stored procedure for the database that needs to collect execution plans (optional)
DELIMITER $$
CREATE PROCEDURE <db_name>.explain_statement(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 ;
GRANT EXECUTE ON PROCEDURE <db_name>.explain_statement TO datakit@'%';
consumers
configuration
Method one (recommended): Dynamic configuration of performance_schema.events_*
with DataKit
requires the creation of the following stored procedure:
DELIMITER $$
CREATE PROCEDURE datakit.enable_events_statements_consumers()
SQL SECURITY DEFINER
BEGIN
UPDATE performance_schema.setup_consumers SET enabled='YES' WHERE name LIKE 'events_statements_%';
UPDATE performance_schema.setup_consumers SET enabled='YES' WHERE name = 'events_waits_current';
END $$
DELIMITER ;
GRANT EXECUTE ON PROCEDURE datakit.enable_events_statements_consumers TO datakit@'%';
Method 2: Manually configure consumers
UPDATE performance_schema.setup_consumers SET enabled='YES' WHERE name LIKE 'events_statements_%';
UPDATE performance_schema.setup_consumers SET enabled='YES' WHERE name = 'events_waits_current';
Replication Metrics Collection¶
To collect replication metrics mysql_replication
, you need to start MySQL replication. mysql_replication
metrics are collected from the replication database, so you can confirm that the MySQL replication environment is working properly by entering them in the slave database:
If the Slave_IO_Running
and Slave_SQL_Running
fields are Yes
, the replication environment is working properly.
To capture group replication metrics such as count_transactions_in_queue
, you need to add the group_replication plugin to the list of plugins loaded by the server at startup (group_replication has been supported since MySQL version 5.7.17). In the configuration file /etc/my.cnf
for the replication database, add the line:
You can confirm that the group replication plugin is installed by showing plugins;
.
To turn it on, you need to perform the following steps.
- Modify the configuration file and start monitoring and collection
[[inputs.mysql]]
## Set replication to true to collect replication metrics
replication = true
## Set group_replication to true to collect group replication metrics
group_replication = true
...
Metric¶
For all of the following data collections, the global election tags will added automatically, we can add extra tags in [inputs.mysql.tags]
if needed:
mysql
¶
- Tags
Tag | Description |
---|---|
host | The server host address |
server | Server addr |
- Metrics
Metric | Description |
---|---|
Aborted_clients | The number of connections that were aborted because the client died without closing the connection properly. Type: int Unit: count |
Aborted_connects | The number of failed attempts to connect to the MySQL server. Type: int Unit: count |
Binlog_cache_disk_use | The number of transactions that used the temporary binary log cache but that exceeded the value of binlog_cache_size and used a temporary file to store statements from the transaction. Type: int Unit: digital,B |
Binlog_cache_use | The number of transactions that used the binary log cache. Type: int Unit: digital,B |
Binlog_space_usage_bytes | Total binary log file size. Type: int Unit: digital,B |
Bytes_received | The number of bytes received from all clients. Type: int Unit: digital,B |
Bytes_sent | The number of bytes sent to all clients. Type: int Unit: digital,B |
Com_commit | The number of times of commit statement has been executed. Type: int Unit: count |
Com_delete | The number of times of delete statement has been executed. Type: int Unit: count |
Com_delete_multi | The number of times of delete-multi statement has been executed. Type: int Unit: count |
Com_insert | The number of times of insert statement has been executed. Type: int Unit: count |
Com_insert_select | The number of times of insert-select statement has been executed. Type: int Unit: count |
Com_load | The number of times of load statement has been executed. Type: int Unit: count |
Com_replace | The number of times of replace statement has been executed. Type: int Unit: count |
Com_replace_select | The number of times of replace-select statement has been executed. Type: int Unit: count |
Com_rollback | The number of times of rollback statement has been executed. Type: int Unit: count |
Com_select | The number of times of select statement has been executed. Type: int Unit: count |
Com_update | The number of times of update statement has been executed. Type: int Unit: count |
Com_update_multi | The number of times of update-mult has been executed. Type: int Unit: count |
Connections | The rate of connections to the server. Type: int Unit: count |
Created_tmp_disk_tables | The rate of internal on-disk temporary tables created by second by the server while executing statements. Type: int Unit: count |
Created_tmp_files | The rate of temporary files created by second. Type: int Unit: count |
Created_tmp_tables | The rate of internal temporary tables created by second by the server while executing statements. Type: int Unit: count |
Handler_commit | The number of internal COMMIT statements. Type: int Unit: count |
Handler_delete | The number of internal DELETE statements. Type: int Unit: count |
Handler_prepare | The number of internal PREPARE statements. Type: int Unit: count |
Handler_read_first | The number of internal READ_FIRST statements. Type: int Unit: count |
Handler_read_key | The number of internal READ_KEY statements. Type: int Unit: count |
Handler_read_next | The number of internal READ_NEXT statements. Type: int Unit: count |
Handler_read_prev | The number of internal READ_PREV statements. Type: int Unit: count |
Handler_read_rnd | The number of internal READ_RND statements. Type: int Unit: count |
Handler_read_rnd_next | The number of internal READ_RND_NEXT statements. Type: int Unit: count |
Handler_rollback | The number of internal ROLLBACK statements. Type: int Unit: count |
Handler_update | The number of internal UPDATE statements. Type: int Unit: count |
Handler_write | The number of internal WRITE statements. Type: int Unit: count |
Key_buffer_bytes_unflushed | MyISAM key buffer bytes unflushed. Type: int Unit: count |
Key_buffer_bytes_used | MyISAM key buffer bytes used. Type: int Unit: count |
Key_buffer_size | Size of the buffer used for index blocks. Type: int Unit: digital,B |
Key_cache_utilization | The key cache utilization ratio. Type: int Unit: percent,percent |
Key_read_requests | The number of requests to read a key block from the MyISAM key cache. Type: int Unit: count |
Key_reads | The number of physical reads of a key block from disk into the MyISAM key cache. If Key_reads is large, then your key_buffer_size value is probably too small. The cache miss rate can be calculated as Key_reads/Key_read_requests. Type: int Unit: count |
Key_write_requests | The number of requests to write a key block to the MyISAM key cache. Type: int Unit: count |
Key_writes | The number of physical writes of a key block from the MyISAM key cache to disk. Type: int Unit: count |
Max_used_connections | The maximum number of connections that have been in use simultaneously since the server started. Type: int Unit: count |
Mysqlx_ssl_ctx_verify_depth | The certificate verification depth limit currently set in ctx. Type: int Unit: count |
Open_files | The number of open files. Type: int Unit: count |
Open_tables | The number of of tables that are open. Type: int Unit: count |
Opened_tables | The number of tables that have been opened. If Opened_tables is big, your table_open_cache value is probably too small. Type: int Unit: count |
Qcache_free_blocks | The number of free memory blocks in the query cache. Type: int Unit: digital,B |
Qcache_free_memory | The amount of free memory for the query cache. Type: int Unit: digital,B |
Qcache_hits | The rate of query cache hits. Type: int Unit: count |
Qcache_inserts | The number of queries added to the query cache. Type: int Unit: count |
Qcache_lowmem_prunes | The number of queries that were deleted from the query cache because of low memory. Type: int Unit: count |
Qcache_not_cached | The number of noncached queries (not cacheable, or not cached due to the query_cache_type setting). Type: int Unit: count |
Qcache_queries_in_cache | The number of queries registered in the query cache. Type: int Unit: count |
Qcache_total_blocks | The total number of blocks in the query cache. Type: int Unit: count |
Queries | The rate of queries. Type: int Unit: count |
Questions | The rate of statements executed by the server. Type: int Unit: count |
Select_full_join | The number of joins that perform table scans because they do not use indexes. If this value is not 0, you should carefully check the indexes of your tables. Type: int Unit: count |
Select_full_range_join | The number of joins that used a range search on a reference table. Type: int Unit: count |
Select_range | The number of joins that used ranges on the first table. This is normally not a critical issue even if the value is quite large. Type: int Unit: count |
Select_range_check | The number of joins without keys that check for key usage after each row. If this is not 0, you should carefully check the indexes of your tables. Type: int Unit: count |
Select_scan | The number of joins that did a full scan of the first table. Type: int Unit: count |
Slow_queries | The rate of slow queries. Type: int Unit: count |
Sort_merge_passes | The number of merge passes that the sort algorithm has had to do. If this value is large, you should consider increasing the value of the sort_buffer_size system variable. Type: int Unit: count |
Sort_range | The number of sorts that were done using ranges. Type: int Unit: count |
Sort_rows | The number of sorted rows. Type: int Unit: count |
Sort_scan | The number of sorts that were done by scanning the table. Type: int Unit: count |
Ssl_ctx_verify_depth | The certificate verification depth limit currently set in ctx. Type: int Unit: count |
Table_locks_immediate | The number of times that a request for a table lock could be granted immediately. Type: int Unit: count |
Table_locks_waited | The total number of times that a request for a table lock could not be granted immediately and a wait was needed. Type: int Unit: count |
Threads_cached | The number of threads in the thread cache. Type: int Unit: count |
Threads_connected | The number of currently open connections. Type: int Unit: count |
Threads_created | The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. Type: int Unit: count |
Threads_running | The number of threads that are not sleeping. Type: int Unit: count |
connection_memory_limit | Set the maximum amount of memory that can be used by a single user connection. Type: int Unit: digital,B |
global_connection_memory_limit | The total amount of memory that can be used by all user connections. Type: int Unit: digital,B |
max_connections | The maximum number of connections that have been in use simultaneously since the server started. Type: int Unit: count |
max_join_size | This represents a limit on the maximum number of row accesses in base tables made by a join. Type: int Unit: count |
max_seeks_for_key | Limit the assumed maximum number of seeks when looking up rows based on a key. Type: int Unit: count |
max_write_lock_count | After this many write locks, permit some pending read lock requests to be processed in between. Type: int Unit: count |
myisam_mmap_size | The maximum amount of memory to use for memory mapping compressed MyISAM files. Type: int Unit: digital,B |
parser_max_mem_size | The maximum amount of memory available to the parser. Type: int Unit: digital,B |
query_cache_size | The amount of memory allocated for caching query results. Type: int Unit: digital,B |
sql_select_limit | The maximum number of rows to return from SELECT statements. Type: int Unit: count |
table_open_cache | The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. Type: int Unit: count |
thread_cache_size | How many threads the server should cache for reuse. When a client disconnects, the client's threads are put in the cache if there are fewer than thread_cache_size threads there. Type: int Unit: digital,B |
mysql_replication
¶
- Tags
Tag | Description |
---|---|
host | The server host address |
server | Server addr |
- Metrics
Metric | Description |
---|---|
Auto_Position | 1 if auto-positioning is in use; otherwise 0. Type: bool Unit: count |
Connect_Retry: | The number of seconds between connect retries (default 60). This can be set with the CHANGE MASTER TO statement. Type: int Unit: count |
Exec_Master_Log_Pos | The position in the current source binary log file to which the SQL thread has read and executed, marking the start of the next transaction or event to be processed. Type: int Unit: count |
Last_Errno | These columns are aliases for Last_SQL_Errno Type: int Unit: count |
Last_IO_Errno | The error number of the most recent error that caused the I/O thread to stop. An error number of 0 and message of the empty string mean “no error.” Type: int Unit: count |
Last_SQL_Errno | The error number of the most recent error that caused the SQL thread to stop. An error number of 0 and message of the empty string mean “no error.” Type: int Unit: count |
Master_Server_Id | The server_id value from the source. Type: int Unit: count |
Relay_Log_Space | The total combined size of all existing relay log files. Type: int Unit: count |
Replicas_connected | Number of replicas connected to a replication source. Type: int Unit: count |
SQL_Delay | The number of seconds that the replica must lag the source. Type: int Unit: count |
Seconds_Behind_Master | The lag in seconds between the master and the slave. Type: int Unit: count |
Skip_Counter | The current value of the sql_slave_skip_counter system variable. Type: int Unit: count |
Slave_IO_Running | Whether the I/O thread is started and has connected successfully to the source. 1 if the state is Yes, 0 if the state is No. Type: bool Unit: count |
Slave_SQL_Running | Whether the SQL thread is started. 1 if the state is Yes, 0 if the state is No. Type: bool Unit: count |
count_conflicts_detected | The number of transactions that have not passed the conflict detection check. Collected as group replication metric. Type: int Unit: count |
count_transactions_checked | The number of transactions that have been checked for conflicts. Collected as group replication metric. Type: int Unit: count |
count_transactions_in_queue | The number of transactions in the queue pending conflict detection checks. Collected as group replication metric. Type: int Unit: count |
count_transactions_local_proposed | The number of transactions which originated on this member and were sent to the group. Collected as group replication metric. Type: int Unit: count |
count_transactions_local_rollback | The number of transactions which originated on this member and were rolled back by the group. Collected as group replication metric. Type: int Unit: count |
count_transactions_remote_applied | The number of transactions this member has received from the group and applied. Collected as group replication metric. Type: int Unit: count |
count_transactions_remote_in_applier_queue | The number of transactions that this member has received from the replication group which are waiting to be applied. Collected as group replication metric. Type: int Unit: count |
count_transactions_rows_validating | The number of transaction rows which can be used for certification, but have not been garbage collected. Collected as group replication metric. Type: int Unit: count |
mysql_schema
¶
MySQL schema information
- Tags
Tag | Description |
---|---|
host | The server host address |
schema_name | Schema name |
server | Server addr |
- Metrics
Metric | Description |
---|---|
query_run_time_avg | Avg query response time per schema. Type: float Unit: time,μs |
schema_size | Size of schemas(MiB) Type: float Unit: digital,MB |
mysql_innodb
¶
- Tags
Tag | Description |
---|---|
host | The server host address |
server | Server addr |
- Metrics
Metric | Description |
---|---|
active_transactions | The number of active transactions on InnoDB tables Type: int Unit: count |
adaptive_hash_searches | Number of successful searches using Adaptive Hash Index Type: int Unit: count |
adaptive_hash_searches_btree | Number of searches using B-tree on an index search Type: int Unit: count |
buffer_data_reads | Amount of data read in bytes (innodb_data_reads) Type: int Unit: count |
buffer_data_written | Amount of data written in bytes (innodb_data_written) Type: int Unit: count |
buffer_pages_created | Number of pages created (innodb_pages_created) Type: int Unit: count |
buffer_pages_read | Number of pages read (innodb_pages_read) Type: int Unit: count |
buffer_pages_written | Number of pages written (innodb_pages_written) Type: int Unit: count |
buffer_pool_bytes_data | The total number of bytes in the InnoDB buffer pool containing data. The number includes both dirty and clean pages. Type: int Unit: digital,B |
buffer_pool_bytes_dirty | Buffer bytes containing data (innodb_buffer_pool_bytes_data) Type: int Unit: count |
buffer_pool_pages_data | Buffer pages containing data (innodb_buffer_pool_pages_data) Type: int Unit: count |
buffer_pool_pages_dirty | Buffer pages currently dirty (innodb_buffer_pool_pages_dirty) Type: int Unit: count |
buffer_pool_pages_flushed | The number of requests to flush pages from the InnoDB buffer pool Type: int Unit: count |
buffer_pool_pages_free | Buffer pages currently free (innodb_buffer_pool_pages_free) Type: int Unit: count |
buffer_pool_pages_misc | Buffer pages for misc use such as row locks or the adaptive hash index (innodb_buffer_pool_pages_misc) Type: int Unit: count |
buffer_pool_pages_total | Total buffer pool size in pages (innodb_buffer_pool_pages_total) Type: int Unit: count |
buffer_pool_read_ahead | Number of pages read as read ahead (innodb_buffer_pool_read_ahead) Type: int Unit: count |
buffer_pool_read_ahead_evicted | Read-ahead pages evicted without being accessed (innodb_buffer_pool_read_ahead_evicted) Type: int Unit: count |
buffer_pool_read_ahead_rnd | The number of random read-aheads initiated by InnoDB. This happens when a query scans a large portion of a table but in random order.Type: int Unit: count |
buffer_pool_read_requests | Number of logical read requests (innodb_buffer_pool_read_requests) Type: int Unit: count |
buffer_pool_reads | Number of reads directly from disk (innodb_buffer_pool_reads) Type: int Unit: count |
buffer_pool_size | Server buffer pool size (all buffer pools) in bytes Type: int Unit: count |
buffer_pool_wait_free | Number of times waited for free buffer (innodb_buffer_pool_wait_free) Type: int Unit: count |
buffer_pool_write_requests | Number of write requests (innodb_buffer_pool_write_requests) Type: int Unit: count |
checkpoint_age | Checkpoint age as shown in the LOG section of the SHOW ENGINE INNODB STATUS outputType: int Unit: count |
current_transactions | Current InnoDB transactionsType: int Unit: count |
data_fsyncs | The number of fsync() operations per second. Type: int Unit: count |
data_pending_fsyncs | The current number of pending fsync() operations. Type: int Unit: count |
data_pending_reads | The current number of pending reads. Type: int Unit: count |
data_pending_writes | The current number of pending writes. Type: int Unit: count |
data_read | The amount of data read per second. Type: int Unit: digital,B |
data_written | The amount of data written per second. Type: int Unit: digital,B |
dblwr_pages_written | The number of pages written per second to the doublewrite buffer.Type: int Unit: count |
dblwr_writes | The number of doublewrite operations performed per second.Type: int Unit: digital,B |
dml_deletes | Number of rows deleted Type: int Unit: count |
dml_inserts | Number of rows inserted Type: int Unit: count |
dml_updates | Number of rows updated Type: int Unit: count |
file_num_open_files | Number of files currently open (innodb_num_open_files) Type: int Unit: count |
hash_index_cells_total | Total number of cells of the adaptive hash index Type: int Unit: count |
hash_index_cells_used | Number of used cells of the adaptive hash index Type: int Unit: count |
history_list_length | History list length as shown in the TRANSACTIONS section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
ibuf_free_list | Insert buffer free list, as shown in the INSERT BUFFER AND ADAPTIVE HASH INDEX section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
ibuf_merged | Insert buffer and adaptative hash index mergedType: int Unit: count |
ibuf_merged_delete_marks | Insert buffer and adaptative hash index merged delete marksType: int Unit: count |
ibuf_merged_deletes | Insert buffer and adaptative hash index merged deleteType: int Unit: count |
ibuf_merged_inserts | Insert buffer and adaptative hash index merged insertsType: int Unit: count |
ibuf_merges | Number of change buffer merges Type: int Unit: count |
ibuf_merges_delete | Number of purge records merged by change buffering Type: int Unit: count |
ibuf_merges_delete_mark | Number of deleted records merged by change buffering Type: int Unit: count |
ibuf_merges_discard_delete | Number of purge merged operations discarded Type: int Unit: count |
ibuf_merges_discard_delete_mark | Number of deleted merged operations discarded Type: int Unit: count |
ibuf_merges_discard_insert | Number of insert merged operations discarded Type: int Unit: count |
ibuf_merges_insert | Number of inserted records merged by change buffering Type: int Unit: count |
ibuf_size | Change buffer size in pages Type: int Unit: count |
innodb_activity_count | Current server activity count Type: int Unit: count |
innodb_dblwr_pages_written | Number of pages that have been written for doublewrite operations (innodb_dblwr_pages_written)Type: int Unit: count |
innodb_dblwr_writes | Number of doublewrite operations that have been performed (innodb_dblwr_writes)Type: int Unit: count |
innodb_page_size | InnoDB page size in bytes (innodb_page_size) Type: int Unit: count |
innodb_rwlock_s_os_waits | Number of OS waits due to shared latch request Type: int Unit: count |
innodb_rwlock_s_spin_rounds | Number of rwlock spin loop rounds due to shared latch request Type: int Unit: count |
innodb_rwlock_s_spin_waits | Number of rwlock spin waits due to shared latch request Type: int Unit: count |
innodb_rwlock_sx_os_waits | Number of OS waits due to sx latch request Type: int Unit: count |
innodb_rwlock_sx_spin_rounds | Number of rwlock spin loop rounds due to sx latch request Type: int Unit: count |
innodb_rwlock_sx_spin_waits | Number of rwlock spin waits due to sx latch request Type: int Unit: count |
innodb_rwlock_x_os_waits | Number of OS waits due to exclusive latch request Type: int Unit: count |
innodb_rwlock_x_spin_rounds | Number of rwlock spin loop rounds due to exclusive latch request Type: int Unit: count |
innodb_rwlock_x_spin_waits | Number of rwlock spin waits due to exclusive latch request Type: int Unit: count |
lock_deadlocks | Number of deadlocks Type: int Unit: count |
lock_row_lock_current_waits | Number of row locks currently being waited for (innodb_row_lock_current_waits) Type: int Unit: count |
lock_row_lock_time | Time spent in acquiring row locks, in milliseconds (innodb_row_lock_time) Type: int Unit: time,ms |
lock_row_lock_time_avg | The average time to acquire a row lock, in milliseconds (innodb_row_lock_time_avg) Type: int Unit: time,ms |
lock_row_lock_time_max | The maximum time to acquire a row lock, in milliseconds (innodb_row_lock_time_max) Type: int Unit: time,ms |
lock_row_lock_waits | Number of times a row lock had to be waited for (innodb_row_lock_waits) Type: int Unit: count |
lock_structs | Lock structs Type: int Unit: count |
lock_timeouts | Number of lock timeouts Type: int Unit: count |
locked_tables | Locked tables Type: int Unit: count |
locked_transactions | Locked transactions Type: int Unit: count |
log_padded | Bytes of log padded for log write ahead Type: int Unit: count |
log_waits | Number of log waits due to small log buffer (innodb_log_waits) Type: int Unit: count |
log_write_requests | Number of log write requests (innodb_log_write_requests) Type: int Unit: count |
log_writes | Number of log writes (innodb_log_writes) Type: int Unit: count |
lsn_current | Log sequence number as shown in the LOG section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
lsn_flushed | Flushed up to log sequence number as shown in the LOG section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
lsn_last_checkpoint | Log sequence number last checkpoint as shown in the LOG section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
mem_adaptive_hash | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: digital,B |
mem_additional_pool | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: digital,B |
mem_dictionary | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: digital,B |
mem_file_system | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: digital,B |
mem_lock_system | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
mem_page_hash | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
mem_recovery_system | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
mem_thread_hash | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
mem_total | As shown in the BUFFER POOL AND MEMORY section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
os_data_fsyncs | Number of fsync() calls (innodb_data_fsyncs) Type: int Unit: count |
os_data_reads | Number of reads initiated (innodb_data_reads) Type: int Unit: count |
os_data_writes | Number of writes initiated (innodb_data_writes) Type: int Unit: count |
os_file_fsyncs | (Delta) The total number of fsync() operations performed by InnoDB. Type: int Unit: count |
os_file_reads | (Delta) The total number of files reads performed by read threads within InnoDB. Type: int Unit: count |
os_file_writes | (Delta) The total number of file writes performed by write threads within InnoDB. Type: int Unit: count |
os_log_bytes_written | Bytes of log written (innodb_os_log_written) Type: int Unit: count |
os_log_fsyncs | Number of fsync log writes (innodb_os_log_fsyncs) Type: int Unit: count |
os_log_pending_fsyncs | Number of pending fsync write (innodb_os_log_pending_fsyncs) Type: int Unit: count |
os_log_pending_writes | Number of pending log file writes (innodb_os_log_pending_writes) Type: int Unit: count |
os_log_written | Number of bytes written to the InnoDB log. Type: int Unit: digital,B |
pages_created | Number of InnoDB pages created. Type: int Unit: count |
pages_read | Number of InnoDB pages read. Type: int Unit: count |
pages_written | Number of InnoDB pages written. Type: int Unit: count |
pending_aio_log_ios | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_aio_sync_ios | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_buffer_pool_flushes | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_checkpoint_writes | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_ibuf_aio_reads | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_log_flushes | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_log_writes | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_normal_aio_reads | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
pending_normal_aio_writes | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
queries_inside | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
queries_queued | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
read_views | As shown in the FILE I/O section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
rows_deleted | Number of rows deleted from InnoDB tables. Type: int Unit: count |
rows_inserted | Number of rows inserted into InnoDB tables. Type: int Unit: count |
rows_read | Number of rows read from InnoDB tables. Type: int Unit: count |
rows_updated | Number of rows updated in InnoDB tables. Type: int Unit: count |
s_lock_os_waits | As shown in the SEMAPHORES section of the SHOW ENGINE INNODB STATUS outputType: int Unit: count |
s_lock_spin_rounds | As shown in the SEMAPHORES section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
s_lock_spin_waits | As shown in the SEMAPHORES section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
semaphore_wait_time | Semaphore wait time Type: int Unit: count |
semaphore_waits | The number semaphore currently being waited for by operations on InnoDB tables. Type: int Unit: count |
tables_in_use | Tables in use Type: int Unit: count |
trx_rseg_history_len | Length of the TRX_RSEG_HISTORY list Type: int Unit: count |
x_lock_os_waits | As shown in the SEMAPHORES section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
x_lock_spin_rounds | As shown in the SEMAPHORES section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
x_lock_spin_waits | As shown in the SEMAPHORES section of the SHOW ENGINE INNODB STATUS output.Type: int Unit: count |
mysql_table_schema
¶
MySQL table information
- Tags
Tag | Description |
---|---|
engine | The storage engine for the table. See The InnoDB Storage Engine, and Alternative Storage Engines. |
host | The server host address |
server | Server addr |
table_name | The name of the table. |
table_schema | The name of the schema (database) to which the table belongs. |
table_type | BASE TABLE for a table, VIEW for a view, or SYSTEM VIEW for an INFORMATION_SCHEMA table. |
version | The version number of the table's .frm file. |
- Metrics
Metric | Description |
---|---|
data_free | The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40% to 50%. In such cases, use SELECT COUNT() to obtain an accurate count. Type: int Unit: count* |
data_length | For InnoDB, DATA_LENGTH is the approximate amount of space allocated for the clustered index, in bytes. Specifically, it is the clustered index size, in pages, multiplied by the InnoDB page size Type: int Unit: count |
index_length | For InnoDB, INDEX_LENGTH is the approximate amount of space allocated for non-clustered indexes, in bytes. Specifically, it is the sum of non-clustered index sizes, in pages, multiplied by the InnoDB page size Type: int Unit: count |
table_rows | The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40% to 50%. In such cases, use SELECT COUNT() to obtain an accurate count. Type: int Unit: count* |
mysql_user_status
¶
MySQL user information
- Tags
Tag | Description |
---|---|
host | The server host address |
server | The server address containing both host and port |
user | user |
- Metrics
Metric | Description |
---|---|
bytes_received | The number of bytes received this user Type: int Unit: count |
bytes_sent | The number of bytes sent this user Type: int Unit: count |
current_connect | The number of current connect Type: int Unit: count |
max_execution_time_exceeded | The number of SELECT statements for which the execution timeout was exceeded. Type: int Unit: count |
max_execution_time_set | The number of SELECT statements for which a nonzero execution timeout was set. This includes statements that include a nonzero MAX_EXECUTION_TIME optimizer hint, and statements that include no such hint but execute while the timeout indicated by the max_execution_time system variable is nonzero. Type: int Unit: count |
max_execution_time_set_failed | The number of SELECT statements for which the attempt to set an execution timeout failed. Type: int Unit: count |
slow_queries | The number of queries that have taken more than long_query_time seconds. This counter increments regardless of whether the slow query log is enabled Type: int Unit: count |
sort_rows | The number of sorted rows. Type: int Unit: count |
sort_scan | The number of sorts that were done by scanning the table. Type: int Unit: count |
table_open_cache_hits | The number of hits for open tables cache lookups. Type: int Unit: count |
table_open_cache_misses | The number of misses for open tables cache lookups. Type: int Unit: count |
table_open_cache_overflows | The number of overflows for the open tables cache. This is the number of times, after a table is opened or closed, a cache instance has an unused entry and the size of the instance is larger than table_open_cache / table_open_cache_instances. Type: int Unit: count |
total_connect | The number of total connect Type: int Unit: count |
collector
¶
- Tags
Tag | Description |
---|---|
instance | Server addr of the instance |
job | Server name of the instance |
- Metrics
Metric | Description |
---|---|
up | Type: int Unit: - |
Object¶
database
¶
MySQL object metrics( Version-1.74.0)
- Tags
Tag | Description |
---|---|
database_type | The type of the database. The value is MySQL |
host | The hostname of the MySQL server |
name | The name of the database. The value is host:port in default |
port | The port of the MySQL server |
server | The server address of the MySQL server |
version | The version of the MySQL server |
- Metrics
Metric | Description |
---|---|
avg_query_time | The average time taken by a query to execute Type: float Unit: timeStamp,usec |
message | Summary of database information Type: string Unit: - |
qps | The number of queries executed by the database per second Type: float Unit: gauge |
slow_queries | The number of queries that have taken more than long_query_time seconds. This counter increments regardless of whether the slow query log is enabled. Type: int Unit: count |
slow_query_log | Whether the slow query log is enabled. The value can be 0 (or OFF) to disable the log or 1 (or ON) to enable the log. Type: string Unit: - |
tps | The number of transactions executed by the database per second Type: float Unit: gauge |
uptime | The number of seconds that the server has been up Type: int Unit: time,s |
message
Metric Field Structure¶
The basic structure of the message
field is as follows:
{
"setting": {
"auto_generate_certs": "ON",
...
},
"databases": [ # databases information
{
"name": "db1",
"default_character_set_name": "utf8mb4",
"default_collation_name": "utf8mb4_general_ci",
"tables": [ # tables information
{
"name": "table1",
"columns": [], # columns information
"indexes": [], # indexes information
"foreign_keys": [], # foreign keys information
"partitions": [] # partitions information
}
...
]
}
...
]
}
setting
¶
The setting
field contains data sourced from the performance_schema.global_variables
table, which holds global variable information for the MySQL server. Detailed fields can be referenced in the MySQL Documentation
databases
¶
The databases
field stores information about all databases on the MySQL server. Each database entry includes the following:
Field Name | Description | Type |
---|---|---|
name |
Database name | string |
default_character_set_name |
Default character set for the database (e.g., utf8mb4) | string |
default_collation_name |
Default collation for the database (e.g., utf8mb4_general_ci) | string |
tables |
List containing table information | list |
tables
¶
The tables
field contains information about all tables in the database. Each table entry includes:
Field Name | Description | Type |
---|---|---|
name |
Table name | string |
columns |
List containing column information | list |
indexes |
List containing index information | list |
foreign_keys |
List containing foreign key information | list |
partitions |
List containing partition information | list |
Details of the list fields:
tables.columns
field
The tables.columns
field contains information about all columns in the table. Each column entry includes:
Field Name | Description | Type |
---|---|---|
name |
Column name | string |
data_type |
Data type (e.g., int) | string |
default |
Default value (NULL is converted to empty string) | string |
nullable |
Whether NULL values are allowed (True indicates NULL is allowed, corresponding to NULL in SQL) | bool |
ordinal_position |
The sequential position of the column in the table (starting from 1) | string |
tables.indexes
The tables.indexes
field contains information about all indexes in the table. Each index entry includes:
Field Name | Description | Type |
---|---|---|
name |
Index name | string |
cardinality |
Estimated number of unique values in the index | string |
index_type |
Index type | string |
columns |
Columns included in the index | list |
non_unique |
Whether the index allows duplicate values (True indicates non-unique) | bool |
expression |
Index expression (only present if the index is based on an expression) | string |
The index column information field indexes.columns
contains details about the columns included in the index. Each column entry includes:
Field Name | Description | Type |
---|---|---|
name |
Column name | string |
sub_part |
Number of characters indexed for partial indexes (e.g., 10 for indexing the first 10 characters of a varchar column) |
int |
collation |
Column collation | string |
packed |
Index storage format | string |
nullable |
Whether the column allows NULL values | string |
tables.foreign_keys
The tables.foreign_keys
field contains information about all foreign keys in the table. Each foreign key entry includes:
Field Name | Description | Type |
---|---|---|
constraint_schema |
Database to which the foreign key belongs (typically the same as the table's database) | string |
name |
Foreign key constraint name | string |
column_names |
Names of foreign key columns (comma-separated for multiple columns, e.g., user_id, order_id) | string |
referenced_table_schema |
Database of the referenced table | string |
referenced_table_name |
Name of the referenced table | string |
referenced_column_names |
Names of referenced columns (comma-separated) | string |
update_action |
Cascade update rule (e.g., CASCADE, RESTRICT) | string |
delete_action |
Cascade delete rule (e.g., CASCADE, SET NULL) | string |
tables.partitions
The tables.partitions
field contains information about all partitions in the table. Each partition entry includes:
Field Name | Description | Type |
---|---|---|
name |
Partition name | string |
subpartitions |
List of dictionaries containing subpartition information (only valid if subpartitions exist) |
list |
partition_ordinal_position |
Sequential position of the partition in the table | int |
partition_method |
Partitioning method (e.g., RANGE, LIST) | string |
partition_expression |
Partition expression (e.g., COLUMN(id)) | string |
partition_description |
Partition description (e.g., VALUES LESS THAN (100)) | string |
table_rows |
Number of rows in the partition (total rows including all subpartitions ) |
int |
data_length |
Size of partition data (in bytes, total size including all subpartitions ) |
int |
The subpartition
information field partitions.subpartitions
contains details about subpartitions
. Each subpartition
entry includes:
Field Name | Description | Type |
---|---|---|
subpartition_ordinal_position |
Sequential position of the subpartition within the partition |
string |
subpartition_method |
Subpartitioning method (e.g., HASH, KEY) |
string |
subpartition_expression |
Subpartition expression |
string |
table_rows |
Number of rows in the subpartition |
int |
data_length |
Size of subpartition data (in bytes) |
int |
Log¶
mysql_dbm_metric
¶
Record the number of executions of the query statement, wait time, lock time, and the number of rows queried.
- Tags
Tag | Description |
---|---|
digest | The digest hash value computed from the original normalized statement. |
host | The server host address |
query_signature | The hash value computed from digest_text |
schema_name | The schema name |
server | The server address containing both host and port |
service | The service name and the value is 'mysql' |
- Metrics
Metric | Description |
---|---|
count_star | The total count of executed queries per normalized query and schema. Type: int Unit: count |
message | The text of the normalized statement digest. Type: string Unit: N/A |
sum_errors | The total count of queries run with an error per normalized query and schema. Type: int Unit: count |
sum_lock_time | The total time(nanosecond) spent waiting on locks per normalized query and schema. Type: int Unit: count |
sum_no_good_index_used | The total count of queries which used a sub-optimal index per normalized query and schema. Type: int Unit: count |
sum_no_index_used | The total count of queries which do not use an index per normalized query and schema. Type: int Unit: count |
sum_rows_affected | The number of rows mutated per normalized query and schema. Type: int Unit: count |
sum_rows_examined | The number of rows examined per normalized query and schema. Type: int Unit: count |
sum_rows_sent | The number of rows sent per normalized query and schema. Type: int Unit: count |
sum_select_full_join | The total count of full table scans on a joined table per normalized query and schema. Type: int Unit: count |
sum_select_scan | The total count of full table scans on the first table per normalized query and schema. Type: int Unit: count |
sum_timer_wait | The total query execution time(nanosecond) per normalized query and schema. Type: int Unit: count |
mysql_dbm_sample
¶
Select some of the SQL statements with high execution time, collect their execution plans, and collect various performance indicators during the actual execution process.
- Tags
Tag | Description |
---|---|
current_schema | The name of the current schema. |
digest | The digest hash value computed from the original normalized statement. |
digest_text | The digest_text of the statement. |
host | The server host address |
network_client_ip | The ip address of the client |
plan_definition | The plan definition of JSON format. |
plan_signature | The hash value computed from plan definition. |
processlist_db | The name of the database. |
processlist_user | The user name of the client. |
query_signature | The hash value computed from digest_text. |
query_truncated | It indicates whether the query is truncated. |
resource_hash | The hash value computed from SQL text. |
server | The server address containing both host and port |
service | The service name and the value is 'mysql' |
- Metrics
Metric | Description |
---|---|
duration | Value in nanoseconds of the event's duration. Type: float Unit: count |
lock_time_ns | Time in nanoseconds spent waiting for locks. Type: int Unit: count |
message | The text of the normalized statement digest. Type: string Unit: N/A |
no_good_index_used | 0 if a good index was found for the statement, 1 if no good index was found. Type: int Unit: enum |
no_index_used | 0 if the statement performed a table scan with an index, 1 if without an index. Type: int Unit: enum |
rows_affected | Number of rows the statement affected. Type: int Unit: count |
rows_examined | Number of rows read during the statement's execution. Type: int Unit: count |
rows_sent | Number of rows returned. Type: int Unit: count |
select_full_join | Number of joins performed by the statement which did not use an index. Type: int Unit: count |
select_full_range_join | Number of joins performed by the statement which used a range search of the int first table. Type: int Unit: count |
select_range | Number of joins performed by the statement which used a range of the first table. Type: int Unit: count |
select_range_check | Number of joins without keys performed by the statement that check for key usage after int each row. Type: int Unit: count |
select_scan | Number of joins performed by the statement which used a full scan of the first table. Type: int Unit: count |
sort_merge_passes | Number of merge passes by the sort algorithm performed by the statement. Type: int Unit: count |
sort_range | Number of sorts performed by the statement which used a range. Type: int Unit: count |
sort_rows | Number of rows sorted by the statement. Type: int Unit: count |
sort_scan | Number of sorts performed by the statement which used a full table scan. Type: int Unit: count |
timer_wait_ns | Value in nanoseconds of the event's duration Type: float Unit: time,ns |
timestamp | The timestamp(millisecond) when then the event ends. Type: float Unit: timeStamp,msec |
mysql_dbm_activity
¶
Collect the waiting event of the current thread
- Tags
Tag | Description |
---|---|
host | The server host address |
server | The server address |
service | The service name and the value is 'mysql' |
- Metrics
Metric | Description |
---|---|
connections | The total number of the connection Type: int Unit: count |
current_schema | The default database for the statement, NULL if there is none Type: string Unit: N/A |
end_event_id | The thread current event number when the event ends Type: string Unit: N/A |
event_id | The event id Type: string Unit: N/A |
event_name | The name of the instrument that produced the event Type: string Unit: N/A |
event_source | The name of the source file Type: string Unit: N/A |
event_timer_end | The time when event timing ended Type: int Unit: time,ns |
event_timer_start | The time when event timing started Type: int Unit: time,ns |
event_timer_wait | The time the event has elapsed so far Type: int Unit: time,ns |
index_name | The name of the index used Type: string Unit: N/A |
ip | The client IP address Type: string Unit: N/A |
lock_time | The time spent waiting for table locks Type: int Unit: time,ns |
message | The text of the normalized SQL text Type: string Unit: N/A |
object_name | The name of the object being acted on Type: string Unit: N/A |
object_schema | The schema of th object being acted on Type: string Unit: N/A |
object_type | The type of the object being acted on Type: string Unit: N/A |
port | The TCP/IP port number, in the range from 0 to 65535 Type: string Unit: N/A |
processlist_command | The command of the thread Type: string Unit: N/A |
processlist_db | The default database for the thread, or NULL if none has been selected Type: string Unit: N/A |
processlist_host | The host name of the client with a thread Type: string Unit: N/A |
processlist_id | The process list ID Type: string Unit: N/A |
processlist_state | The state of the thread Type: string Unit: N/A |
processlist_user | The user associated with a thread Type: string Unit: N/A |
query_signature | The hash value computed from SQL text Type: string Unit: N/A |
socket_event_name | The name of the wait/io/socket/* instrument that produced the eventType: string Unit: - |
sql_text | The statement the thread is executing Type: string Unit: N/A |
thread_id | The thread ID Type: string Unit: N/A |
wait_event | The name of the wait event Type: string Unit: N/A |
wait_timer_end | The time when the waiting event timing ended Type: int Unit: time,ns |
wait_timer_start | The time when the waiting event timing started Type: int Unit: time,ns |
mysql_replication_log
¶
Record the replication string information.
- Tags
Tag | Description |
---|---|
host | The server host address |
server | Server addr |
- Metrics
Metric | Description |
---|---|
Executed_Gtid_Set | The set of global transaction IDs written in the binary log. Type: string Unit: N/A |
Master_Host | The host name of the master. Type: string Unit: N/A |
Master_Log_File | The name of the binary log file from which the server is reading. Type: string Unit: N/A |
Master_Port | The network port used to connect to the master. Type: int Unit: count |
Master_User | The user name used to connect to the master. Type: string Unit: N/A |
MySQL Run Log¶
If you need to collect MySQL log, open the log-related configuration in the configuration. If you need to open MySQL slow query log, you need to open the slow query log. Execute the following statements in MySQL.
SET GLOBAL slow_query_log = 'ON';
-- Queries that do not use indexes are also considered a possible slow query
set global log_queries_not_using_indexes = 'ON';
Note: When using log collection, you need to install the DataKit on the same host as the MySQL service, or use other methods to mount the log on the machine where the DataKit is located.
MySQL logs are divided into normal logs and slow logs.
MySQL Normal Logs¶
Original log:
2017-12-29T12:33:33.095243Z 2 Query SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE CREATE_OPTIONS LIKE '%partitioned%';
The list of cut fields is as follows:
Field Name | Field Value | Description |
---|---|---|
status |
Warning |
log level |
msg |
System table 'plugin' is expected to be transactional. |
log content |
time |
1514520249954078000 |
Nanosecond timestamp (as row protocol time) |
MySQL Slow Query Log¶
Original log:
# Time: 2019-11-27T10:43:13.460744Z
# User@Host: root[root] @ localhost [1.2.3.4] Id: 35
# Query_time: 0.214922 Lock_time: 0.000184 Rows_sent: 248832 Rows_examined: 72
# Thread_id: 55 Killed: 0 Errno: 0
# Bytes_sent: 123456 Bytes_received: 0
SET timestamp=1574851393;
SELECT * FROM fruit f1, fruit f2, fruit f3, fruit f4, fruit f5
The list of cut fields is as follows:
Field Name | Field Value | Description |
---|---|---|
bytes_sent |
123456 |
Number of bytes sent |
db_host |
localhost |
hostname |
db_ip |
1.2.3.4 |
ip |
db_slow_statement |
SET timestamp=1574851393;\nSELECT * FROM fruit f1, fruit f2, fruit f3, fruit f4, fruit f5 |
Slow query SQL |
db_user |
root[root] |
User |
lock_time |
0.000184 |
Lock time |
query_id |
35 |
query id |
query_time |
0.2l4922 |
Time spent on SQL execution |
rows_examined |
72 |
Number of rows read to return queried data |
rows_sent |
248832 |
Number of rows returned by query |
thread_id |
55 |
Thread id |
time |
1514520249954078000 |
Nanosecond timestamp (as line protocol time) |
FAQ¶
Why the measurement mysql_user_status
is not collected for Aliyun RDS?¶
The measurement is collected from MySQL performance_schema
. You should check if it is enabled by the SQL below:
show variables like "performance_schema";
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| performance_schema | ON |
+--------------------+-------+
If the value is OFF
, please refer to the document to enable it.