MySQL
The MySQL source collects metrics and logs from a MySQL server. Metrics are scraped over a database connection (host/port, a monitoring username and password, transport), covering buffer pool, InnoDB, index, table, connection, replica, and query activity. Logs are read from the general, slow query, and error log files and parsed into structured records. Choose either or both signals with Choose Telemetry Type.
Supported Telemetry Types
Linux
✓
✓
Windows
✓
✓
macOS
✓
✓
Prerequisites
For metrics:
A reachable MySQL endpoint (host and port, default
localhost:3306), or a Unix socket when using theunixtransport.A dedicated monitoring user with the minimum privileges the receiver needs. Use a least-privilege account rather than an administrative login. Most metrics require the ability to run
SHOW GLOBAL STATUS;performance_schemabased metrics (query, statement, and lock-wait timing) additionally requireSELECTonperformance_schema. GrantREPLICATION CLIENTandPROCESSfor replica and process metrics. See Creating MySQL User Accounts for monitoring and the mysqlreceiver README for the exact grants.Network reachability from the collector host to the MySQL port.
For logs:
MySQL configured to write the log files you want to collect (general log, slow query log, error log). See MySQL Server Logs.
The collector running on the MySQL host (or with access to the log files) and read access to the configured log paths.
Configuration

Telemetry Type
Choose Telemetry Type
Telemetry Selector
No
["Logs", "Metrics"]
Which signals this source collects: Logs, Metrics, or both.
Logs
Shown when Choose Telemetry Type includes Logs.
Enable General Log
Boolean
No
true
Enable to read and parse the general log file.
Enable Slow Log
Boolean
No
true
Enable to read and parse the slow query log.
Enable Error Log
Boolean
No
true
Enable to read and parse the error log.
Metrics
Shown when Choose Telemetry Type includes Metrics.
Username
String
Yes
(empty)
Username used to authenticate.
Password
String
Yes
(empty)
Password used to authenticate. Stored as a sensitive value.
Endpoint
String
No
localhost:3306
The endpoint of the MySQL server.
Transport
Enum: tcp, unix
No
tcp
The transport protocol used to connect to MySQL.
Advanced
General Log Path
Strings
No
/var/log/mysql/general.log
Path to the general log file(s). Shown when Logs is selected and Enable General Log is true.
Slow Query Log Path
Strings
No
/var/log/mysql/slow*.log
Path to the slow query log file(s). Shown when Logs is selected and Enable Slow Log is true.
Error Log Path
Strings
No
/var/log/mysqld.log, /var/log/mysql/mysqld.log, /var/log/mysql/error.log
Path to the error log file(s). Defaults cover CentOS/RHEL, SLES, and Debian/Ubuntu. Shown when Logs is selected and Enable Error Log is true.
Start At
Enum: beginning, end
No
end
Start reading logs from the beginning or end of the file. Shown when Logs is selected.
Parse
Boolean
No
true
Parses the log fields into structured data. Shown when Logs is selected.
Filtering
Metrics
No
See note
Per-metric enable/disable selection. Some metrics are disabled by default and can be enabled here. Shown when Metrics is selected.
Database
String
No
(empty)
The database name. If not specified, metrics are collected for all databases. Shown when Metrics is selected.
Collection Interval
Integer
No
60
How often (seconds) to scrape for metrics. Shown when Metrics is selected.
The Filtering parameter exposes metrics grouped into Buffer Pool, General, Index, Table, Connection, Replica, and Query categories. Metrics disabled by default include mysql.commands, mysql.client.network.io, the mysql.table.lock_wait.* set, mysql.connection.count, mysql.connection.errors, mysql.joins, mysql.replica.time_behind_source, mysql.replica.sql_delay, mysql.statement_event.count, mysql.statement_event.wait.time, mysql.mysqlx_worker_threads, mysql.table_open_cache, mysql.query.client.count, mysql.query.count, and mysql.query.slow.count.
Examples
Metrics from a remote MySQL server with a monitoring user
Scrape metrics from a remote MySQL instance every 30 seconds using a dedicated monitoring account, with logs disabled.
Logs only from the standard Debian/Ubuntu paths
Collect and parse the general, slow query, and error logs from the default paths, reading new lines as they arrive.
Configuration Tips
Use a dedicated, least-privilege monitoring user for metrics rather than an administrative account. Grant only
SHOW GLOBAL STATUSaccess plusSELECTonperformance_schemafor the query, statement, and lock-wait metrics you intend to enable.The query, statement, and lock-wait metrics are disabled by default. Enable them in Filtering only if your monitoring user has
performance_schemaaccess, otherwise they will not populate.Leave Database empty to collect metrics across all databases; set it to scope collection to a single database.
Troubleshooting
Connection refused
Symptoms: the receiver cannot reach the MySQL server.
Solutions:
Verify the Endpoint host and port and that MySQL is listening on it.
Confirm the collector host can reach the port (firewall, security group,
bind-addressin the MySQL config).
Authentication failed
Symptoms: access-denied errors on connect.
Solutions:
Verify the Username and Password.
Confirm the monitoring user is allowed to connect from the collector's host (the host portion of the MySQL account) and has the required grants.
Query, statement, or lock-wait metrics missing
Symptoms: enabled performance_schema based metrics never appear.
Solutions:
Confirm
performance_schemais enabled on the server.Grant the monitoring user
SELECTonperformance_schema(andUPDATEonperformance_schema.setup_consumersfor lock-wait timing).
No logs collected
Symptoms: log files are enabled but no records flow.
Solutions:
Confirm MySQL is writing the relevant log files and the configured paths match.
Verify the collector has read access to the log paths.
Standalone Source
Related Resources
Last updated
Was this helpful?