
Parameter | Description |
name | Exporter name, which should meet the following requirements: The name should be unique. The name should conform to the following regular expression: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$'. |
username | MySQL username. |
password | MySQL password. |
address | MySQL connection address |
tag | Custom labels for metrics. |
Exporter Configuration | auto_increment.columns: Collect auto_increment columns and maximum value from information_schema. binlog_size: Collect the current size of all registered binlog files. engine_innodb_status: Collect from SHOW ENGINE INNODB STATUS. engine_tokudb_status: Collect from SHOW ENGINE TOKUDB STATUS. global_status: Collect from SHOW GLOBAL STATUS. The default is true. global_variables: Collect from SHOW GLOBAL VARIABLES. The default is true. info_schema.clientstats: Set to true to collect client statistical information if running with userstat=1. info_schema.innodb_metrics: Collect metrics from information_schema.innodb_metrics. info_schema.innodb_tablespaces: Collect metrics from information_schema.innodb_sys_tablespaces. info_schema.innodb_cmp: Collect InnoDB compressed table metrics from information_schema.innodb_cmp. The default is true. info_schema.innodb_cmpmem: Collect InnoDB buffer pool compression metrics from information_schema.innodb_cmpmem. The default is true. info_schema.processlist: Collect thread state counting from information_schema.processlist. info_schema.query_response_time: Collect query response time distribution if query_response_time_stats is ON. The default is true. info_schema.tables: Collect metrics from information_schema.tables. info_schema.tables.databases: Designed to collect the database list for table statistics, comma-separated. The default is '*' which means all databases. info_schema.tablestats: Set to true to collect table statistics if running with userstat=1. info_schema.schemastats: Set to true to collect schema statistics if running with userstat=1. info_schema.userstats: Set to true to collect user statistical information if running with userstat=1. perf_schema.eventsstatements: Collect metrics from performance_schema.events_statements_summary_by_digest. perf_schema.eventsstatements.digest_text_limit: Maximum length of standardized statement text, default value is 120. perf_schema.eventsstatements.limit: Limit the number of event statement summaries by response time, default value is 250. perf_schema.eventsstatements.timelimit: Limit the Max Time for 'last_seen' event statements, in seconds, default value is 86400. perf_schema.eventsstatementssum: Aggregate metrics from performance_schema.events_statements_summary_by_digest. perf_schema.eventswaits: Collect metrics from performance_schema.events_waits_summary_global_by_event_name. perf_schema.file_events: Collect metrics from performance_schema.file_summary_by_event_name. perf_schema.file_instances: Collect metrics from performance_schema.file_summary_by_instance. perf_schema.indexiowaits: Collect metrics from performance_schema.table_io_waits_summary_by_index_usage. perf_schema.tableiowaits: Collect metrics from performance_schema.table_io_waits_summary_by_table. perf_schema.tablelocks: Collect metrics from performance_schema.table_lock_waits_summary_by_table. perf_schema.replication_group_member_stats: Collect metrics from performance_schema.replication_group_member_stats. perf_schema.replication_applier_status_by_worker: Collect metrics from performance_schema.replication_applier_status_by_worker. slave_status: Collect from SHOW SLAVE STATUS. The default is true. slave_hosts: Collect from SHOW SLAVE HOSTS. heartbeat: Collect from heartbeat. heartbeat.database: Database for heartbeat data collection. Default value is heartbeat. heartbeat.table: Table for heartbeat data collection. Default value is heartbeat. |

CREATE USER 'exporter'@'ip' IDENTIFIED BY 'password' WITH MAX_USER_CONNECTIONS 3;GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'ip';
apiVersion: v1kind: Secretmetadata:name: mysql-secret-testnamespace: mysql-demotype: OpaquestringData:datasource: "user:password@tcp(ip:port)/" #corresponds to MySQL connection string information
apiVersion: apps/v1kind: Deploymentmetadata:labels:k8s-app: mysql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MySQL instance.name: mysql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MySQL instance.namespace: mysql-demospec:replicas: 1selector:matchLabels:k8s-app: mysql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MySQL instance.template:metadata:labels:k8s-app: mysql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MySQL instance.spec:containers:- env:- name: DATA_SOURCE_NAMEvalueFrom:secretKeyRef:name: mysql-secret-test # Corresponds to the name of the Secret in the previous step.key: datasource # Corresponds to the Secret Key in the previous step.image: ccr.ccs.tencentyun.com/rig-agent/mysqld-exporter:v0.12.1imagePullPolicy: IfNotPresentname: mysql-exporterports:- containerPort: 9104name: metric-portterminationMessagePath: /dev/termination-logterminationMessagePolicy: FilednsPolicy: ClusterFirstimagePullSecrets:- name: qcloudregistrykeyrestartPolicy: AlwaysschedulerName: default-schedulersecurityContext: {}terminationGracePeriodSeconds: 30

wget -O- localhost:9104/metrics

apiVersion: monitoring.coreos.com/v1kind: PodMonitormetadata:name: mysql-exporter # Enter a unique name.namespace: cm-prometheus # Pay-as-you-go instance: cluster namespace; Annual and monthly subscription instances (no longer available): namespace is fixed, do not changespec:podMetricsEndpoints:- interval: 30sport: metric-port # Enter the port of the Prometheus Exporter in the Pod YAML file.path: /metrics # Enter the path of the Prometheus Exporter. Default value: /metrics.relabelings:- action: replacesourceLabels:- instanceregex: (.*)targetLabel: instancereplacement: 'cdb-xxxxxx' # Replace with the corresponding MySQL instance ID- action: replacesourceLabels:- instanceregex: (.*)targetLabel: ipreplacement: '1.x.x.x' # Replace with the corresponding MySQL instance IPnamespaceSelector: # Select the namespace where the Pod to be monitored is located.matchNames:- mysql-demoselector: # Enter the labels of the Pod to be monitored to locate the target Pod.matchLabels:k8s-app: mysql-exporter


Collector to control data collection. Specific parameters are as follows:Parameter | MySQL Version | Description |
collect.auto_increment.columns | 5.1 | Collects auto_increment columns and max values from information_schema. |
collect.binlog_size | 5.1 | Collects the current size of all registered binlog files. |
collect.engine_innodb_status | 5.1 | Collects the status data from SHOW ENGINE INNODB STATUS. |
collect.engine_tokudb_status | 5.6 | Collects the status data from SHOW ENGINE TOKUDB STATUS. |
collect.global_status | 5.1 | Collects the status data from SHOW GLOBAL STATUS (enabled by default). |
collect.global_variables | 5.1 | Collects the status data from SHOW GLOBAL VARIABLES (enabled by default). |
collect.info_schema.clientstats | 5.5 | If userstat=1 is set, this parameter can be set to true to enable client data collection. |
collect.info_schema.innodb_metrics | 5.6 | Collects the monitoring data from information_schema.innodb_metrics. |
collect.info_schema.innodb_tablespaces | 5.7 | Collects the monitoring data from information_schema.innodb_sys_tablespaces. |
collect.info_schema.innodb_cmp | 5.5 | Collects the monitoring data of compressed InnoDB tables from information_schema.innodb_cmp. |
collect.info_schema.innodb_cmpmem | 5.5 | Collects the monitoring data of InnoDB buffer pool compression from information_schema.innodb_cmpmem. |
collect.info_schema.processlist | 5.1 | Collects the monitoring data of the thread status count from information_schema.processlist. |
collect.info_schema.processlist.min_time | 5.1 | Minimum time a thread must be in each status to be counted. Default value: 0 |
collect.info_schema.query_response_time | 5.5 | Collects query response time distribution if query_response_time_stats is set to ON. |
collect.info_schema.replica_host | 5.6 | Collects the status data from information_schema.replica_host_status. |
collect.info_schema.tables | 5.1 | Collects the status data from information_schema.tables. |
collect.info_schema.tables.databases | 5.1 | Sets the list of databases to collect table statistics for, or ' *' for all. |
collect.info_schema.tablestats | 5.1 | If userstat=1 is set, this parameter can be set to true to collect table statistics. |
collect.info_schema.schemastats | 5.1 | If userstat=1 is set, this parameter can be set to true to collect schema statistics. |
collect.info_schema.userstats | 5.1 | If userstat=1 is set, this parameter can be set to true to collect user statistics. |
collect.perf_schema.eventsstatements | 5.6 | Collects the monitoring data from performance_schema.events_statements_summary_by_digest. |
collect.perf_schema.eventsstatements.digest_text_limit | 5.6 | Sets the maximum length of the normalized statement text. Default value: 120. |
collect.perf_schema.eventsstatements.limit | 5.6 | Limits the number of event statements. Default value: 250. |
collect.perf_schema.eventsstatements.timelimit | 5.6 | Limits how old the 'last_seen' events statements can be, in seconds. Default value: 86400. |
collect.perf_schema.eventsstatementssum | 5.7 | Collects the monitoring data from performance_schema.events_statements_summary_by_digest summed. |
collect.perf_schema.eventswaits | 5.5 | Collects the monitoring data from performance_schema.events_waits_summary_global_by_event_name. |
collect.perf_schema.file_events | 5.6 | Collects the monitoring data from performance_schema.file_summary_by_event_name. |
collect.perf_schema.file_instances | 5.5 | Collects the monitoring data from performance_schema.file_summary_by_instance. |
collect.perf_schema.indexiowaits | 5.6 | Collects the monitoring data from performance_schema.table_io_waits_summary_by_index_usage. |
collect.perf_schema.tableiowaits | 5.6 | Collects the monitoring data from performance_schema.table_io_waits_summary_by_table. |
collect.perf_schema.tablelocks | 5.6 | Collects the monitoring data from performance_schema.table_lock_waits_summary_by_table. |
collect.perf_schema.replication_group_members | 5.7 | Collects the monitoring data from performance_schema.replication_group_members. |
collect.perf_schema.replication_group_member_stats | 5.7 | Collects the monitoring data from performance_schema.replication_group_member_stats. |
collect.perf_schema.replication_applier_status_by_worker | 5.7 | Collects the monitoring data from performance_schema.replication_applier_status_by_worker. |
collect.slave_status | 5.1 | Collects the monitoring data from SHOW SLAVE STATUS (enabled by default). |
collect.slave_hosts | 5.1 | Collects the monitoring data from SHOW SLAVE HOSTS. |
collect.heartbeat | 5.1 | |
collect.heartbeat.database | 5.1 | Database from where to collect heartbeat data. Default value: heartbeat. |
collect.heartbeat.table | 5.1 | Table from where to collect heartbeat data. Default value: heartbeat. |
collect.heartbeat.utc | 5.1 | Uses UTC for timestamps of the current server ( pt-heartbeat is called with --utc). Default value: false. |
Item | Description |
config.my-cnf | Path of .my.cnf file to read MySQL credentials from. Default value: ~/.my.cnf. |
log.level | Log level. Default value: info. |
exporter.lock_wait_timeout | Sets a lock_wait_timeout (in seconds) on the connection to avoid long metadata locking. Default value: 2. |
exporter.log_slow_filter | Adds a log_slow_filter to avoid slow query logging of scrapes. Note: Oracle MySQL is not supported. |
web.listen-address | Web port listening address. |
web.telemetry-path | Metric API path. |
version | Prints the version information. |
collect.heartbeat is enabled, mysqld_exporter will scrape replication delay measured by heartbeat mechanisms.Feedback