Project: Netdata (Observability and Analysis / Observability)
File: percona_mysql.md

<!--startmeta customediturl: "https://github.com/netdata/netdata/edit/master/src/go/collectors/go.d.plugin/modules/mysql/integrations/percona_mysql.md" meta_yaml: "https://github.com/netdata/netdata/edit/master/src/go/collectors/go.d.plugin/modules/mysql/metadata.yaml" sidebar_label: "Percona MySQL" learn_status: "Published" learnrelpath: "Collecting Metrics/Databases" most_popular: False message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE" endmeta--> <img src="https://netdata.cloud/img/percona.svg" width="150"/> Plugin: go.d.plugin Module: mysql <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" /> This collector monitors the health and performance of MySQL servers and collects general statistics, replication and user metrics. It connects to the MySQL instance via a TCP or UNIX socket and executes the following commands: Executed queries: `SELECT VERSION();` `SHOW GLOBAL STATUS;` `SHOW GLOBAL VARIABLES;` `SHOW SLAVE STATUS;` or `SHOW ALL SLAVES STATUS;` (MariaDBv10.2+) or `SHOW REPLICA STATUS;` (MySQL 8.0.22+) `SHOW USER_STATISTICS;` (MariaDBv10.1.1+) `SELECT TIME,USER FROM INFORMATION_SCHEMA.PROCESSLIST;` This collector is supported on all platforms. This collector supports collecting metrics from multiple instances of this integration, including remote instances. By default, it detects instances running on localhost by trying to connect as root and netdata using known MySQL TCP and UNIX sockets: /var/run/mysqld/mysqld.sock /var/run/mysqld/mysql.sock /var/lib/mysql/mysql.sock /tmp/mysql.sock 127.0.0.1:3306 "[::1]:3306" The default configuration for this integration does not impose any limits on data collection. The default configuration for this integration is not expected to impose a significant performance impact on the system. Metrics grouped by scope. The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels. These metrics refer to the entire monitored application. This scope has no labels. Metrics: | Metric | Dimensions | Unit | MySQL | MariaDB | Percona | |:|:-|:-|::|::|::| | mysql.net | in, out | kilobits/s | | | | | mysql.queries | queries, questions, slow_queries | queries/s | | | | | mysql.queries_type | select, delete, update, insert, replace | queries/s | | | | | mysql.handlers | commit, delete, prepare, readfirst, readkey, readnext, readprev, readrnd, readrnd_next, rollback, savepoint, savepointrollback, update, write | handlers/s | | | | | mysql.tableopencacheoverflows | opencache | overflows/s | | | | | mysql.table_locks | immediate, waited | locks/s | | | | | mysql.joinissues | fulljoin, fullrangejoin, range, range_check, scan | joins/s | | | | | mysql.sortissues | mergepasses, range, scan | issues/s | | | | | mysql.tmp | disk_tables, files, tables | events/s | | | | | mysql.connections | all, aborted | connections/s | | | | | mysql.connectionsactive | active, limit, maxactive | connections | | | | | mysql.threads | connected, cached, running | threads | | | | | mysql.threads_created | created | threads/s | | | | | mysql.threadcachemisses | misses | misses | | | | | mysql.innodb_io | read, write | KiB/s | | | | | mysql.innodbioops | reads, writes, fsyncs | operations/s | | | | | mysql.innodbiopending_ops | reads, writes, fsyncs | operations | | | | | mysql.innodblog | waits, writerequests, writes | operations/s | | | | | mysql.innodbcurrow_lock | current waits | operations | | | | | mysql.innodb_rows | inserted, read, updated, deleted | operations/s | | | | | mysql.innodbbufferpool_pages | data, dirty, free, misc, total | pages | | | | | mysql.innodbbufferpoolpagesflushed | flush_pages | requests/s | | | | | mysql.innodbbufferpool_bytes | data, dirty | MiB | | | | | mysql.innodbbufferpoolreadahead | all, evicted | pages/s | | | | | mysql.innodbbufferpoolreadahead_rnd | read-ahead | operations/s | | | | | mysql.innodbbufferpoolops | diskreads, wait_free | operations/s | | | | | mysql.innodboslog | fsyncs, writes | operations | | | | |

| fsyncs | operations/s | | | | | mysql.innodboslog_io | write | KiB/s | | | | | mysql.innodb_deadlocks | deadlocks | operations/s | | | | | mysql.files | files | files | | | | | mysql.files_rate | files | files/s | | | | | mysql.connectionerrors | accept, internal, max, peeraddr, select, tcpwrap | errors/s | | | | | mysql.opened_tables | tables | tables/s | | | | | mysql.open_tables | cache, tables | tables | | | | | mysql.processlistfetchqueryduration | duration | milliseconds | | | | | mysql.processlistqueries_count | system, user | queries | | | | | mysql.processlistlongestqueryduration | duration | seconds | | | | | mysql.qcacheops | hits, lowmemprunes, inserts, not_cached | queries/s | | | | | mysql.qcache | queries | queries | | | | | mysql.qcache_freemem | free | MiB | | | | | mysql.qcache_memblocks | free, total | blocks | | | | | mysql.galera_writesets | rx, tx | writesets/s | | | | | mysql.galera_bytes | rx, tx | KiB/s | | | | | mysql.galera_queue | rx, tx | writesets | | | | | mysql.galeraconflicts | bfaborts, cert_fails | transactions | | | | | mysql.galeraflowcontrol | paused | ms | | | | | mysql.galeraclusterstatus | primary, non_primary, disconnected | status | | | | | mysql.galeraclusterstate | undefined, joining, donor, joined, synced, error | state | | | | | mysql.galeraclustersize | nodes | nodes | | | | | mysql.galeraclusterweight | weight | weight | | | | | mysql.galera_connected | connected | boolean | | | | | mysql.galera_ready | ready | boolean | | | | | mysql.galeraopentransactions | open | transactions | | | | | mysql.galerathreadcount | threads | threads | | | | | mysql.keyblocks | unused, used, notflushed | blocks | | | | | mysql.key_requests | reads, writes | requests/s | | | | | mysql.keydiskops | reads, writes | operations/s | | | | | mysql.binlog_cache | disk, all | transactions/s | | | | | mysql.binlogstmtcache | disk, all | statements/s | | | | These metrics refer to the replication connection. This scope has no labels. Metrics: | Metric | Dimensions | Unit | MySQL | MariaDB | Percona | |:|:-|:-|::|::|::| | mysql.slave_behind | seconds | seconds | | | | | mysql.slavestatus | sqlrunning, io_running | boolean | | | | These metrics refer to the MySQL user. Labels: | Label | Description | |:--|:-| | user | username | Metrics: | Metric | Dimensions | Unit | MySQL | MariaDB | Percona | |:|:-|:-|::|::|::| | mysql.userstats_cpu | used | percentage | | | | | mysql.userstats_rows | read, sent, updated, inserted, deleted | operations/s | | | | | mysql.userstats_commands | select, update, other | commands/s | | | | | mysql.userstatsdeniedcommands | denied | commands/s | | | | | mysql.userstatscreatedtransactions | commit, rollback | transactions/s | | | | | mysql.userstatsbinlogwritten | written | B/s | | | | | mysql.userstatsemptyqueries | empty | queries/s | | | | | mysql.userstats_connections | created | connections/s | | | | | mysql.userstatslostconnections | lost | connections/s | | | | | mysql.userstatsdeniedconnections | denied | connections/s | | | | The following alerts are available: | Alert name | On metric | Description | |:|:-|:| | |

| number of slow queries in the last 10 seconds | | | mysql.table_locks | number of table immediate locks in the last 10 seconds | | | mysql.table_locks | number of table waited locks in the last 10 seconds | | | mysql.table_locks | ratio of waited table locks over the last 10 seconds | | | mysql.connections_active | client connections utilization | | | mysql.slave_status | replication status (0: stopped, 1: working) | | | mysql.slave_behind | difference between the timestamp of the latest transaction processed by the SQL thread and the timestamp of the same transaction when it was processed on the master | | | mysql.galeraclustersize | maximum galera cluster size in the last 2 minutes starting one minute ago | | | mysql.galeraclustersize | current galera cluster size, compared to the maximum size in the last 2 minutes | | | mysql.galeraclusterstate | galera node state is either Donor/Desynced or Joined | | | mysql.galeraclusterstate | galera node state is either Undefined or Joining or Error | | | mysql.galeraclusterstatus | galera node is part of a nonoperational component. This occurs in cases of multiple membership changes that result in a loss of Quorum or in cases of split-brain situations. | A user account should have the following : To create the `netdata` user with these permissions, execute the following in the MySQL shell: ```mysql CREATE USER 'netdata'@'localhost'; GRANT USAGE, REPLICATION CLIENT, PROCESS ON . TO 'netdata'@'localhost'; FLUSH PRIVILEGES; ``` The `netdata` user will have the ability to connect to the MySQL server on localhost without a password. It will only be able to gather statistics without being able to alter or affect operations in any way. The configuration file name for this integration is `go.d/mysql.conf`. You can edit the configuration file using the `edit-config` script from the Netdata . ```bash cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata sudo ./edit-config go.d/mysql.conf ``` The following options can be defined globally: updateevery, autodetectionretry. <details><summary>Config options</summary> | Name | Description | Default | Required | |:-|:--|:-|:--:| | update_every | Data collection frequency. | 5 | no | | autodetection_retry | Recheck interval in seconds. Zero means no recheck will be scheduled. | 0 | no | | dsn | MySQL server DSN (Data Source Name). See . | root@tcp(localhost:3306)/ | yes | | my.cnf | Specifies the my.cnf file to read the connection settings from the [client] section. | | no | | timeout | Query timeout in seconds. | 1 | no | </details> An example configuration. <details><summary>Config</summary> ```yaml jobs: name: local dsn: netdata@tcp(127.0.0.1:3306)/ ``` </details> An example configuration. <details><summary>Config</summary> ```yaml jobs: name: local dsn: netdata@unix(/var/lib/mysql/mysql.sock)/ ``` </details> An example configuration. <details><summary>Config</summary> ```yaml jobs: name: local dsn: netconfig:password@tcp(127.0.0.1:3306)/ ``` </details> An example configuration. <details><summary>Config</summary> ```yaml jobs: name: local my.cnf: '/etc/my.cnf' ``` </details> Note: When you define multiple jobs, their names must be unique. Local and remote instances. <details><summary>Config</summary> ```yaml jobs: name: local dsn: netdata@tcp(127.0.0.1:3306)/ name: remote dsn: netconfig:password@tcp(203.0.113.0:3306)/ ``` </details> To troubleshoot issues with the `mysql` collector, run the `go.d.plugin` with the debug option enabled. The output should give you clues as to why the collector isn't working. Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`. ```bash cd /usr/libexec/netdata/plugins.d/ ``` Switch to the `netdata` user. ```bash sudo -u netdata -s ``` Run the `go.d.plugin` to debug the collector: ```bash ./go.d.plugin -d -m mysql ```