How to Set Up MySQL Dashboards in Grafana

Some great Grafana MySQL dashboard options:

Option 1: Official MySQL Dashboard (Recommended)

Dashboard ID: 7362 — MySQL Overview by percona

Import it directly in Grafana:

Dashboards → Import → Enter ID: 7362 → Load

Covers: QPS, connections, InnoDB buffer pool, slow queries, replication lag.


Option 2: Popular Community Dashboards

Dashboard IDNameBest For
7362MySQL Overview (Percona)General purpose
6239MySQL InnoDB MetricsDeep InnoDB tuning
14057MySQL Exporter Quickstartmysqld_exporter default
11323MySQL ReplicationMaster/slave monitoring

Setup Requirements

1. Install mysqld_exporter

# Download
wget https://github.com/prometheus/mysqld_exporter/releases/latest/download/mysqld_exporter-*.linux-amd64.tar.gz
# Create MySQL user for exporter
mysql -u root -p
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'yourpassword' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
2. Configure exporter credentials
# /etc/.my.cnf
[client]
user=exporter
password=yourpassword
3. Run the exporter
./mysqld_exporter --config.my-cnf=/etc/.my.cnf
# Default port: 9104
4. Add to Prometheus scrape config
# prometheus.yml
scrape_configs:
- job_name: 'mysql'
static_configs:
- targets: ['localhost:9104']

Key Metrics to Monitor

# Queries per second
rate(mysql_global_status_queries[5m])
# Active connections
mysql_global_status_threads_connected
# Connection usage %
100 * mysql_global_status_threads_connected
/ mysql_global_variables_max_connections
# Slow queries rate
rate(mysql_global_status_slow_queries[5m])
# InnoDB buffer pool hit rate
(1 - rate(mysql_global_status_innodb_buffer_pool_reads[5m])
/ rate(mysql_global_status_innodb_buffer_pool_read_requests[5m])) * 100
# Replication lag (if replica)
mysql_slave_status_seconds_behind_master

What to Alert On

MetricThresholdSeverity
Connection usage> 80%Warning
Connection usage> 95%Critical
Replication lag> 30sWarning
Slow queries rate> 10/sWarning
Buffer pool hit rate< 95%Warning
Uptime (restarted)< 300sCritical

Quick start: Just import dashboard 7362 — it works out of the box with mysqld_exporter defaults and covers 90% of what you need.

Leave a Reply