Grafana Alloy is the new name for our distribution of the OTel collector. Grafana Agent has been deprecated and is in Long-Term Support (LTS) through October 31, 2025. Grafana Agent will reach an End-of-Life (EOL) on November 1, 2025. Read more about why we recommend migrating to Grafana Alloy.

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source


The prometheus.exporter.mysql component embeds mysqld_exporter for collecting stats from a MySQL server.


prometheus.exporter.mysql "LABEL" {
    data_source_name = DATA_SOURCE_NAME


The following arguments can be used to configure the exporter’s behavior. All arguments are optional. Omitted fields take their default values.

data_source_namesecretData Source Name for the MySQL server to connect to.yes
enable_collectorslist(string)A list of collectors to enable on top of the default
disable_collectorslist(string)A list of collectors to disable from the default
set_collectorslist(string)A list of collectors to run. Fully overrides the default
lock_wait_timeoutintTimeout, in seconds, to acquire a metadata lock.2no
log_slow_filterboolUsed to avoid queries from scrapes being logged in the slow query log.falseno

Set a lock_wait_timeout on the connection to avoid potentially long wait times for metadata locks. View more detailed documentation on lock_wait_timeout in the MySQL documentation.

NOTE: log_slow_filter is not supported by Oracle MySQL.


The following blocks are supported inside the definition of prometheus.exporter.mysql to configure collector-specific options:

info_schema.processlistinfo_schema.processlistConfigures the info_schema.processlist
info_schema.tablesinfo_schema.tablesConfigures the info_schema.tables
perf_schema.eventsstatementsperf_schema.eventsstatementsConfigures the perf_schema.eventsstatements
perf_schema.file_instancesperf_schema.file_instancesConfigures the perf_schema.file_instances
heartbeatheartbeatConfigures the heartbeat
mysql.usermysql.userConfigures the mysql.user

info_schema.processlist block

min_timeintMinimum time a thread must be in each state to be counted.0no
processes_by_userboolEnable collecting the number of processes by user.trueno
processes_by_hostboolEnable collecting the number of processes by host.trueno

info_schema.tables block

info_schema_tables_databasesstringRegular expression to match databases to collect table stats for."*"no

perf_schema.eventsstatements block

limitintLimit the number of events statements digests, in descending order by last_seen.250no
time_limitintLimit how old, in seconds, the last_seen events statements can be.86400no
text_limitintMaximum length of the normalized statement text.120no

perf_schema.file_instances block

filterstringRegular expression to select rows in performance_schema.file_summary_by_instance.".*"no
remove_prefixstringPrefix to trim away from file_name."/var/lib/mysql"no

View more detailed documentation on the tables used in perf_schema_file_instances_filter and perf_schema_file_instances_remove_prefix in the MySQL documentation.

heartbeat block

databasestringDatabase to collect heartbeat data from."heartbeat"no
tablestringTable to collect heartbeat data from."heartbeat"no
utcboolUse UTC for timestamps of the current server (pt-heartbeat is called with --utc).falseno

mysql.user block

privilegesboolEnable collecting user privileges from mysql.user.falseno

Supported Collectors

The full list of supported collectors is:

NameDescriptionEnabled by default
auto_increment.columnsCollect auto_increment columns and max values from
binlog_sizeCollect the current size of all registered binlog
engine_innodb_statusCollect metrics from SHOW ENGINE INNODB
engine_tokudb_statusCollect metrics from SHOW ENGINE TOKUDB
global_statusCollect metrics from SHOW GLOBAL STATUS.yes
global_variablesCollect metrics from SHOW GLOBAL VARIABLES.yes
heartbeatCollect metrics from heartbeat database and
info_schema.clientstatsIf running with userstat=1, enable to collect client
info_schema.innodb_cmpmemCollect metrics from information_schema.innodb_cmpmem.yes
info_schema.innodb_metricsCollect metrics from information_schema.innodb_metrics.yes
info_schema.innodb_tablespacesCollect metrics from
info_schema.processlistCollect current thread state counts from the
info_schema.query_response_timeCollect query response time distribution if query_response_time_stats is ON.yes
info_schema.replica_hostCollect metrics from
info_schema.schemastatsIf running with userstat=1, enable to collect schema
info_schema.tablesCollect metrics from
info_schema.tablestatsIf running with userstat=1, enable to collect table
info_schema.userstatsIf running with userstat=1, enable to collect user
mysql.userCollect data from
perf_schema.eventsstatementsCollect metrics from
perf_schema.eventsstatementssumCollect metrics of grand sums from
perf_schema.eventswaitsCollect metrics from
perf_schema.file_eventsCollect metrics from
perf_schema.file_instancesCollect metrics from
perf_schema.indexiowaitsCollect metrics from
perf_schema.replication_applier_status_by_workerCollect metrics from
perf_schema.replication_group_member_statsCollect metrics from
perf_schema.replication_group_membersCollect metrics from
perf_schema.tableiowaitsCollect metrics from
perf_schema.tablelocksCollect metrics from
slave_hostsScrape information from SHOW SLAVE
slave_statusScrape information from SHOW SLAVE STATUS.yes

Exported fields

The following fields are exported and can be referenced by other components.

targetslist(map(string))The targets that can be used to collect exporter metrics.

For example, the targets can either be passed to a discovery.relabel component to rewrite the targets’ label sets or to a prometheus.scrape component that collects the exposed metrics.

The exported targets use the configured in-memory traffic address specified by the run command.

Component health

prometheus.exporter.mysql is only reported as unhealthy if given an invalid configuration. In those cases, exported fields retain their last healthy values.

Debug information

prometheus.exporter.mysql does not expose any component-specific debug information.

Debug metrics

prometheus.exporter.mysql does not expose any component-specific debug metrics.


This example uses a prometheus.scrape component to collect metrics from prometheus.exporter.mysql:

prometheus.exporter.mysql "example" {
  data_source_name  = "root@(server-a:3306)/"
  enable_collectors = ["heartbeat", "mysql.user"]

// Configure a prometheus.scrape component to collect mysql metrics.
prometheus.scrape "demo" {
  targets    = prometheus.exporter.mysql.example.targets
  forward_to = [prometheus.remote_write.demo.receiver]

prometheus.remote_write "demo" {
  endpoint {

    basic_auth {
      username = USERNAME
      password = PASSWORD

Replace the following:

  • PROMETHEUS_REMOTE_WRITE_URL: The URL of the Prometheus remote_write-compatible server to send metrics to.
  • USERNAME: The username to use for authentication to the remote_write API.
  • PASSWORD: The password to use for authentication to the remote_write API.