{"id":13575478,"url":"https://github.com/prometheus/mysqld_exporter","last_synced_at":"2025-05-13T20:03:06.072Z","repository":{"id":28558075,"uuid":"32075541","full_name":"prometheus/mysqld_exporter","owner":"prometheus","description":"Exporter for MySQL server metrics","archived":false,"fork":false,"pushed_at":"2025-05-01T19:30:50.000Z","size":5688,"stargazers_count":2273,"open_issues_count":188,"forks_count":781,"subscribers_count":51,"default_branch":"main","last_synced_at":"2025-05-06T19:51:53.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://prometheus.io/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prometheus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-03-12T12:23:48.000Z","updated_at":"2025-05-05T19:24:13.000Z","dependencies_parsed_at":"2023-10-03T14:13:04.747Z","dependency_job_id":"54db867a-4da6-41cc-afb7-017fb74cad77","html_url":"https://github.com/prometheus/mysqld_exporter","commit_stats":{"total_commits":543,"total_committers":118,"mean_commits":4.601694915254237,"dds":0.7127071823204421,"last_synced_commit":"2ef168bf68f326cf0f87973a215f9c52163f9bda"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prometheus%2Fmysqld_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prometheus%2Fmysqld_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prometheus%2Fmysqld_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prometheus%2Fmysqld_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prometheus","download_url":"https://codeload.github.com/prometheus/mysqld_exporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020472,"owners_count":22000749,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:01.455Z","updated_at":"2025-05-13T20:03:06.048Z","avatar_url":"https://github.com/prometheus.png","language":"Go","funding_links":[],"categories":["Go","others","Uncategorized","Exporters"],"sub_categories":["Uncategorized","Databases"],"readme":"# MySQL Server Exporter [![Build Status](https://travis-ci.org/prometheus/mysqld_exporter.svg)][travis]\n\n[![CircleCI](https://circleci.com/gh/prometheus/mysqld_exporter/tree/main.svg?style=shield)][circleci]\n[![Docker Repository on Quay](https://quay.io/repository/prometheus/mysqld-exporter/status)][quay]\n[![Docker Pulls](https://img.shields.io/docker/pulls/prom/mysqld-exporter.svg?maxAge=604800)][hub]\n[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/mysqld_exporter)](https://goreportcard.com/report/github.com/prometheus/mysqld_exporter)\n\nPrometheus exporter for MySQL server metrics.\n\nSupported versions:\n* MySQL \u003e= 5.6.\n* MariaDB \u003e= 10.3\n\nNOTE: Not all collection methods are supported on MySQL/MariaDB \u003c 5.6\n\n## Building and running\n\n### Required Grants\n\n```sql\nCREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;\nGRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';\n```\n\nNOTE: It is recommended to set a max connection limit for the user to avoid overloading the server with monitoring scrapes under heavy load. This is not supported on all MySQL/MariaDB versions; for example, MariaDB 10.1 (provided with Ubuntu 18.04) [does _not_ support this feature](https://mariadb.com/kb/en/library/create-user/#resource-limit-options).\n\n### Build\n\n    make build\n\n### Running\n\n#####  Single exporter mode\n\nRunning using `.my.cnf` from the current directory:\n\n    ./mysqld_exporter \u003cflags\u003e\n\n#####  Multi-target support\n\nThis exporter supports the multi-target pattern. This allows running a single instance of this exporter for multiple MySQL targets.\n\nTo use the multi-target functionality, send an http request to the endpoint `/probe?target=foo:3306` where target is set to the DSN of the MySQL instance to scrape metrics from.\n\nTo avoid putting sensitive information like username and password in the URL, you can have multiple configurations in `config.my-cnf` file and match it by adding `\u0026auth_module=\u003csection\u003e` to the request.\n \nSample config file for multiple configurations\n\n        [client]\n        user = foo\n        password = foo123\n        [client.servers]\n        user = bar\n        password = bar123\n\nOn the prometheus side you can set a scrape config as follows\n\n        - job_name: mysql # To get metrics about the mysql exporter’s targets\n          metrics_path: /probe\n          params:\n            # Not required. Will match value to child in config file. Default value is `client`.\n            auth_module: [client.servers]\n          static_configs:\n            - targets:\n              # All mysql hostnames or unix sockets to monitor.\n              - server1:3306\n              - server2:3306\n              - unix:///run/mysqld/mysqld.sock\n          relabel_configs:\n            - source_labels: [__address__]\n              target_label: __param_target\n            - source_labels: [__param_target]\n              target_label: instance\n            - target_label: __address__\n              # The mysqld_exporter host:port\n              replacement: localhost:9104\n\n#####  Flag format\nExample format for flags for version \u003e 0.10.0:\n\n    --collect.auto_increment.columns\n    --no-collect.auto_increment.columns\n\nExample format for flags for version \u003c= 0.10.0:\n\n    -collect.auto_increment.columns\n    -collect.auto_increment.columns=[true|false]\n\n### Collector Flags\n\nName                                                         | MySQL Version | Description\n-------------------------------------------------------------|---------------|------------------------------------------------------------------------------------\ncollect.auto_increment.columns                               | 5.1           | Collect auto_increment columns and max values from information_schema.\ncollect.binlog_size                                          | 5.1           | Collect the current size of all registered binlog files\ncollect.engine_innodb_status                                 | 5.1           | Collect from SHOW ENGINE INNODB STATUS.\ncollect.engine_tokudb_status                                 | 5.6           | Collect from SHOW ENGINE TOKUDB STATUS.\ncollect.global_status                                        | 5.1           | Collect from SHOW GLOBAL STATUS (Enabled by default)\ncollect.global_variables                                     | 5.1           | Collect from SHOW GLOBAL VARIABLES (Enabled by default)\ncollect.heartbeat                                            | 5.1           | Collect from [heartbeat](#heartbeat).\ncollect.heartbeat.database                                   | 5.1           | Database from where to collect heartbeat data. (default: heartbeat)\ncollect.heartbeat.table                                      | 5.1           | Table from where to collect heartbeat data. (default: heartbeat)\ncollect.heartbeat.utc                                        | 5.1           | Use UTC for timestamps of the current server (`pt-heartbeat` is called with `--utc`). (default: false)\ncollect.info_schema.clientstats                              | 5.5           | If running with userstat=1, set to true to collect client statistics.\ncollect.info_schema.innodb_metrics                           | 5.6           | Collect metrics from information_schema.innodb_metrics.\ncollect.info_schema.innodb_tablespaces                       | 5.7           | Collect metrics from information_schema.innodb_sys_tablespaces.\ncollect.info_schema.innodb_cmp                               | 5.5           | Collect InnoDB compressed tables metrics from information_schema.innodb_cmp.\ncollect.info_schema.innodb_cmpmem                            | 5.5           | Collect InnoDB buffer pool compression metrics from information_schema.innodb_cmpmem.\ncollect.info_schema.processlist                              | 5.1           | Collect thread state counts from information_schema.processlist.\ncollect.info_schema.processlist.min_time                     | 5.1           | Minimum time a thread must be in each state to be counted. (default: 0)\ncollect.info_schema.query_response_time                      | 5.5           | Collect query response time distribution if query_response_time_stats is ON.\ncollect.info_schema.replica_host                             | 5.6           | Collect metrics from information_schema.replica_host_status.\ncollect.info_schema.rocksdb_perf_context                     | 5.6           | Collect RocksDB metrics from information_schema.ROCKSDB_PERF_CONTEXT.\ncollect.info_schema.tables                                   | 5.1           | Collect metrics from information_schema.tables.\ncollect.info_schema.tables.databases                         | 5.1           | The list of databases to collect table stats for, or '`*`' for all.\ncollect.info_schema.tablestats                               | 5.1           | If running with userstat=1, set to true to collect table statistics.\ncollect.info_schema.schemastats                              | 5.1           | If running with userstat=1, set to true to collect schema statistics\ncollect.info_schema.userstats                                | 5.1           | If running with userstat=1, set to true to collect user statistics.\ncollect.mysql.user                                           | 5.5             | Collect data from mysql.user table\ncollect.perf_schema.eventsstatements                         | 5.6           | Collect metrics from performance_schema.events_statements_summary_by_digest.\ncollect.perf_schema.eventsstatements.digest_text_limit       | 5.6           | Maximum length of the normalized statement text. (default: 120)\ncollect.perf_schema.eventsstatements.limit                   | 5.6           | Limit the number of events statements digests by response time. (default: 250)\ncollect.perf_schema.eventsstatements.timelimit               | 5.6           | Limit how old the 'last_seen' events statements can be, in seconds. (default: 86400)\ncollect.perf_schema.eventsstatementssum                      | 5.7           | Collect metrics from performance_schema.events_statements_summary_by_digest summed.\ncollect.perf_schema.eventswaits                              | 5.5           | Collect metrics from performance_schema.events_waits_summary_global_by_event_name.\ncollect.perf_schema.file_events                              | 5.6           | Collect metrics from performance_schema.file_summary_by_event_name.\ncollect.perf_schema.file_instances                           | 5.5           | Collect metrics from performance_schema.file_summary_by_instance.\ncollect.perf_schema.file_instances.remove_prefix             | 5.5           | Remove path prefix in performance_schema.file_summary_by_instance.\ncollect.perf_schema.indexiowaits                             | 5.6           | Collect metrics from performance_schema.table_io_waits_summary_by_index_usage.\ncollect.perf_schema.memory_events                            | 5.7           | Collect metrics from performance_schema.memory_summary_global_by_event_name.\ncollect.perf_schema.memory_events.remove_prefix              | 5.7           | Remove instrument prefix in performance_schema.memory_summary_global_by_event_name.\ncollect.perf_schema.tableiowaits                             | 5.6           | Collect metrics from performance_schema.table_io_waits_summary_by_table.\ncollect.perf_schema.tablelocks                               | 5.6           | Collect metrics from performance_schema.table_lock_waits_summary_by_table.\ncollect.perf_schema.replication_group_members                | 5.7           | Collect metrics from performance_schema.replication_group_members.\ncollect.perf_schema.replication_group_member_stats           | 5.7           | Collect metrics from performance_schema.replication_group_member_stats.\ncollect.perf_schema.replication_applier_status_by_worker     | 5.7           | Collect metrics from performance_schema.replication_applier_status_by_worker.\ncollect.slave_status                                         | 5.1           | Collect from SHOW SLAVE STATUS (Enabled by default)\ncollect.slave_hosts                                          | 5.1           | Collect from SHOW SLAVE HOSTS\ncollect.sys.user_summary                                     | 5.7           | Collect metrics from sys.x$user_summary (disabled by default).\n\n\n### General Flags\nName                                       | Description\n-------------------------------------------|--------------------------------------------------------------------------------------------------\nmysqld.address                             | Hostname and port used for connecting to MySQL server, format: `host:port`. (default: `localhost:3306`)\nmysqld.username                            | Username to be used for connecting to MySQL Server\nconfig.my-cnf                              | Path to .my.cnf file to read MySQL credentials from. (default: `~/.my.cnf`)\nlog.level                                  | Logging verbosity (default: info)\nexporter.lock_wait_timeout                 | Set a lock_wait_timeout (in seconds) on the connection to avoid long metadata locking. (default: 2)\nexporter.log_slow_filter                   | Add a log_slow_filter to avoid slow query logging of scrapes.  NOTE: Not supported by Oracle MySQL.\ntls.insecure-skip-verify                   | Ignore tls verification errors.\nweb.config.file                            | Path to a [web configuration file](#tls-and-basic-authentication)\nweb.listen-address                         | Address to listen on for web interface and telemetry.\nweb.telemetry-path                         | Path under which to expose metrics.\nversion                                    | Print the version information.\n\n### Environment Variables\nName                                       | Description\n-------------------------------------------|--------------------------------------------------------------------------------------------------\nMYSQLD_EXPORTER_PASSWORD                   | Password to be used for connecting to MySQL Server\n\n### Configuration precedence\n\nIf you have configured cli with both `mysqld` flags and a valid configuration file, the options in the configuration file will override the flags for `client` section.\n\n## TLS and basic authentication\n\nThe MySQLd Exporter supports TLS and basic authentication.\n\nTo use TLS and/or basic authentication, you need to pass a configuration file\nusing the `--web.config.file` parameter. The format of the file is described\n[in the exporter-toolkit repository](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md).\n\n## Customizing Configuration for a SSL Connection\n\nIf The MySQL server supports SSL, you may need to specify a CA truststore to verify the server's chain-of-trust. You may also need to specify a SSL keypair for the client side of the SSL connection. To configure the mysqld exporter to use a custom CA certificate, add the following to the mysql cnf file:\n\n```\nssl-ca=/path/to/ca/file\n```\n\nTo specify the client SSL keypair, add the following to the cnf.\n\n```\nssl-key=/path/to/ssl/client/key\nssl-cert=/path/to/ssl/client/cert\n```\n\n\n## Using Docker\n\nYou can deploy this exporter using the [prom/mysqld-exporter](https://hub.docker.com/r/prom/mysqld-exporter/) Docker image.\n\nFor example:\n\n```bash\ndocker network create my-mysql-network\ndocker pull prom/mysqld-exporter\n\ndocker run -d \\\n  -p 9104:9104 \\\n  -v /home/user/user_my.cnf:/.my.cnf \\\n  --network my-mysql-network  \\\n  prom/mysqld-exporter\n```\n\n## heartbeat\n\nWith `collect.heartbeat` enabled, mysqld_exporter will scrape replication delay\nmeasured by heartbeat mechanisms. [Pt-heartbeat][pth] is the\nreference heartbeat implementation supported.\n\n[pth]:https://www.percona.com/doc/percona-toolkit/2.2/pt-heartbeat.html\n\n\n## Filtering enabled collectors\n\nThe `mysqld_exporter` will expose all metrics from enabled collectors by default. This is the recommended way to collect metrics to avoid errors when comparing metrics of different families.\n\nFor advanced use the `mysqld_exporter` can be passed an optional list of collectors to filter metrics. The `collect[]` parameter may be used multiple times.  In Prometheus configuration you can use this syntax under the [scrape config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#\u003cscrape_config\u003e).\n\n```yaml\nparams:\n  collect[]:\n  - foo\n  - bar\n```\n\nThis can be useful for having different Prometheus servers collect specific metrics from targets.\n\n## Example Rules\n\nThere is a set of sample rules, alerts and dashboards available in the [mysqld-mixin](mysqld-mixin/)\n\n[circleci]: https://circleci.com/gh/prometheus/mysqld_exporter\n[hub]: https://hub.docker.com/r/prom/mysqld-exporter/\n[travis]: https://travis-ci.org/prometheus/mysqld_exporter\n[quay]: https://quay.io/repository/prometheus/mysqld-exporter\n[parsetime]: https://github.com/go-sql-driver/mysql#parsetime\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprometheus%2Fmysqld_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprometheus%2Fmysqld_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprometheus%2Fmysqld_exporter/lists"}