MySQL receiver
This receiver queries MySQL and MariaDB global status and InnoDB tables.
The MySQL receiver is a component of the OpenTelemetry Collector. It connects to a MySQL or MariaDB instance and supports metrics and logs pipelines.
MySQL and MariaDB support starts from these minimum collector versions:
- Splunk Distribution of the OpenTelemetry Collector (
splunk-otel-collector) v0.154.0 or later - Community (OSS) version of the OpenTelemetry Collector (
opentelemetry-collector-contrib) v0.154.0 or later
Supported versions and platforms
Splunk Database Monitoring supports these MySQL and MariaDB versions and platforms:
- MySQL versions: 5.7+
- MariaDB versions: 10.5+
- Platforms: AWS RDS, standalone
splunk-otel-collector) version 0.161.0 or higher, or Community (OSS) version of the OpenTelemetry Collector (opentelemetry-collector-contrib) version 0.161.0 or higher. See Authenticate to Amazon RDS or Aurora with AWS IAM. IAM database authentication isn't available for standalone MySQL or standalone MariaDB.
Prerequisites
-
Enable performance schema for MySQL and MariaDB:
- AWS RDS
-
-
On the AWS console, navigate to . In your MySQL or MariaDB parameter group, change these values:
-
performance_schema: 1 -
max_digest_length: 4096 -
performance_schema_max_digest_length: 4096 -
performance_schema_max_sql_text_length: 4096 -
(Optional)
require_secure_transport: 0 only if non-TLS connections are allowed
-
-
Save the parameter group.
-
Attach the parameter group to the database instance if it isn't already attached.
-
Restart the database instance.
-
(Optional) Verify:
SQLSHOW VARIABLES LIKE 'performance_schema'; SHOW VARIABLES LIKE 'max_digest_length'; SHOW VARIABLES LIKE 'performance_schema_max_digest_length'; SHOW VARIABLES LIKE 'performance_schema_max_sql_text_length';
Note:-
performance_schema = 1is mandatory. -
Splunk strongly recommends the
4096values for some settings above to reduce query text truncation. -
require_secure_transportis optional and depends on your TLS policy. -
RDS parameter group values must be changed from the AWS Console, AWS CLI, Terraform, or API; not from a normal MySQL or MariaDB SQL session.
-
User creation and grants can still be done from any database client connected to the RDS instance.
Note:These parameter group settings apply to both AWS RDS for MySQL and AWS RDS for MariaDB. MariaDB supports
performance_schema_max_sql_text_lengthandperformance_schema_max_digest_lengthfrom version 10.5.2 onward. All MariaDB versions available on AWS RDS support these settings. -
- Standalone
-
-
Update
my.cnformysqld.cnf. MariaDB also usesmy.cnfwith the same[mysqld]section:SQL[mysqld] performance_schema=ON max_digest_length=4096 performance_schema_max_digest_length=4096 performance_schema_max_sql_text_length=4096In this section, add
require_secure_transport=OFFonly if TLS isn't enabled. -
Restart the database instance.
-
(Optional) Verify:
SQLSHOW VARIABLES LIKE 'performance_schema'; SHOW VARIABLES LIKE 'max_digest_length'; SHOW VARIABLES LIKE 'performance_schema_max_digest_length'; SHOW VARIABLES LIKE 'performance_schema_max_sql_text_length'; SHOW GRANTS FOR 'username'@'%';
Note:-
performance_schema=ONis mandatory. -
The
4096settings are strongly recommended. -
require_secure_transport=OFFis optional. Keep it enabled if TLS is required and configure the receiver accordingly.
Note:MariaDB uses the same configuration file format and
[mysqld]section as MySQL. On MariaDB installations, the configuration file is typically located at/etc/mysql/my.cnf,/etc/my.cnf, or under/etc/mysql/mariadb.conf.d/. The same parameter names and values apply. -
-
Create a database user for the receiver to use.
These commands apply to both AWS RDS and standalone platforms.
Use these privileges to configure the receiver user:
Privilege Required for Applies to REPLICATION CLIENTReplica status monitoring with SHOW SLAVE STATUSorSHOW REPLICA STATUSMySQL SLAVE MONITORReplica status monitoring with SHOW SLAVE STATUSMariaDB 10.5.9+ (use instead of REPLICATION CLIENT)PROCESSInnoDB buffer pool metrics collection MySQL and MariaDB SELECT ON performance_schema.*Query sample and top query collection MySQL and MariaDB SELECT ON schema-name.*EXPLAIN plan collection for queries in that schema MySQL and MariaDB BACKUP_ADMINOptional InnoDB redo-log metrics ( mysql.innodb.redo_log.lsn.current,mysql.innodb.redo_log.lsn.checkpoint, andmysql.innodb.redo_log.checkpoint.age) on MySQL 8.0.11 through 8.0.29 only. Not required on MySQL 8.0.30 and higher.MySQL 8.0.11–8.0.29 - Run these commands:
- MySQL
-
SQL
CREATE USER 'otel-user'@'%' IDENTIFIED BY 'otel-user-password'; -- Required for replica status monitoring GRANT REPLICATION CLIENT ON *.* TO 'otel-user'@'%'; -- Required for InnoDB metrics collection GRANT PROCESS ON *.* TO 'otel-user'@'%'; -- Required for performance-related metadata and query collection GRANT SELECT ON performance_schema.* TO 'otel-user'@'%'; -- MySQL 8.0.11 through 8.0.29 only: required for the optional InnoDB -- redo-log metrics. Skip this on MySQL 8.0.30 and higher. GRANT BACKUP_ADMIN ON *.* TO 'otel-user'@'%'; FLUSH PRIVILEGES;Note:Grant
BACKUP_ADMINonly if your MySQL version is between 8.0.11 and 8.0.29 and you plan to activate the optional InnoDB redo-log metrics. On those versions, the receiver reads redo-log data fromperformance_schema.log_status, which requires this privilege in addition toSELECTonperformance_schema. MySQL 8.0.30 and higher read the same data fromSHOW GLOBAL STATUSand don't needBACKUP_ADMIN. To check your version, runSELECT VERSION();. - MariaDB
-
SQL
CREATE USER 'otel-user'@'%' IDENTIFIED BY 'otel-user-password'; -- Required for replica status monitoring GRANT SLAVE MONITOR ON *.* TO 'otel-user'@'%'; -- Required for InnoDB metrics collection GRANT PROCESS ON *.* TO 'otel-user'@'%'; -- Required for performance-related metadata and query collection GRANT SELECT ON performance_schema.* TO 'otel-user'@'%'; FLUSH PRIVILEGES;Note:Starting with MariaDB 10.5.2, the
REPLICATION CLIENTprivilege was renamed toBINLOG MONITORand the privilege required forSHOW SLAVE STATUSchanged. From MariaDB 10.5.9 onward, useSLAVE MONITOR, also known asREPLICA MONITOR, for replica status monitoring. If you upgrade from an older MariaDB version, existingREPLICATION CLIENTgrants are automatically mapped to the new privilege names.Note:The optional InnoDB redo-log metrics aren't available on MariaDB, and no additional privilege is needed.
BACKUP_ADMINdoesn't exist in MariaDB.
Note:On AWS RDS, you can grant
EXECUTEonmysql.rds_versionto suppress collector log warnings.SQLGRANT EXECUTE ON PROCEDURE mysql.rds_version TO 'otel-user'@'%';Note:Amazon RDS for MySQL doesn't allow the
BACKUP_ADMINprivilege to be granted on MySQL 8.0.36 and higher minor versions, or on MySQL 8.4.3 and higher. Those versions don't require it because the receiver reads redo-log data fromSHOW GLOBAL STATUSinstead. RDS instances running MySQL 8.0.11 through 8.0.29 can still be grantedBACKUP_ADMIN. -
For Amazon RDS for MySQL, Amazon Aurora MySQL, and Amazon RDS for MariaDB, create the monitoring user for AWS IAM database authentication instead of using a static password:
- MySQL
-
SQL
CREATE USER 'otel-user'@'%' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'; GRANT REPLICATION CLIENT ON *.* TO 'otel-user'@'%'; GRANT PROCESS ON *.* TO 'otel-user'@'%'; GRANT SELECT ON performance_schema.* TO 'otel-user'@'%'; ALTER USER 'otel-user'@'%' REQUIRE SSL; - MariaDB
-
SQL
CREATE USER 'otel-user'@'%' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'; GRANT SLAVE MONITOR ON *.* TO 'otel-user'@'%'; GRANT PROCESS ON *.* TO 'otel-user'@'%'; GRANT SELECT ON performance_schema.* TO 'otel-user'@'%'; ALTER USER 'otel-user'@'%' REQUIRE SSL;
Grant
SELECTon all schemas or on specific schemas using the existing commands.Complete the AWS-side setup. For full instructions, see IAM database authentication for MariaDB, MySQL, and PostgreSQL in the Amazon RDS User Guide.
- Activate IAM database authentication on the RDS DB instance or Aurora DB cluster.
- Attach an IAM policy that grants
rds-db:connectto the IAM role that runs the collector:JSON{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["rds-db:connect"], "Resource": ["arn:aws:rds-db:us-east-1:111122223333:dbuser:db-ABCDEFGHIJKL01234/otel-user"] } ] }In the resource ARN, use the
DbiResourceIdof the DB instance for Amazon RDS, or theDbClusterResourceIdof the cluster for Amazon Aurora. The final path segment is the database user name and is case-sensitive. - Make the IAM role available to the collector host through the standard AWS credential chain, such as an Amazon EC2 instance profile, an Amazon ECS task role, or IAM roles for service accounts (IRSA) on Amazon EKS. Don't put AWS access keys in the collector configuration file.
-
Grant the user you created
SELECTaccess to some or all schemas:Note: The MySQL receiver depends on schema-levelSELECTprivileges to retrieveEXPLAINplans. If you don't grant access to a schema, queries from that schema may still appear in the UI, but their correspondingEXPLAINplans will not be visible.- Grant access to all schemas
-
This option grants
SELECTaccess across all schemas. It is the simplest configuration and ensures thatEXPLAINplans for top queries are consistently available in the UI without additional configuration.SQLGRANT SELECT ON *.* TO 'otel-user'@'%'; - Grant access to specific schemas (least privilege)
-
This option limits
SELECTaccess to only the specified schemas. It is recommended for environments with strict access controls.SQLGRANT SELECT ON `schema-name`.* TO 'otel-user'@'%';
Configure the receiver
Modify your collector configuration file as follows. All examples are for the Splunk Distribution of the OpenTelemetry Collector.
-
In the
receivers:section, addmysql:YAMLmysql: collection_interval: 10s endpoint: host:port username: otel-user password: otel-user-password events: db.server.query_sample: enabled: true db.server.top_query: enabled: true resource_attributes: mysql.instance.endpoint: enabled: trueNote: On Amazon RDS for MySQL, Amazon Aurora MySQL, and Amazon RDS for MariaDB, you can replacepasswordwith AWS IAM database authentication. IAM authentication doesn't store a database password in the collector configuration and requirestls.insecure: false. See Authenticate to Amazon RDS or Aurora with AWS IAM.Important:If you're using the Splunk Distribution of OpenTelemetry Collector, leave the following receiver settings at their default values:
collection_interval(Default: 10s)-
query_sample_collection.max_rows_per_query(Default: 100) top_query_collection.collection_interval(Default: 60s)-
top_query_collection.max_query_sample_count(Default: 1000)
These values support Database Monitoring without affecting the performance of the database or the collector. If you increase these values you might adversely affect the performance of your database or collector, and this could result in ingest throttling.
-
In the
processors:section, add this:YAMLresource/mysql_service_instance_id: attributes: - action: insert from_attribute: mysql.instance.endpoint key: service.instance.id -
In the
exporters:section, addotlp_http/dbmon:YAMLotlp_http/dbmon: headers: X-SF-Token: your-splunk-access-token X-splunk-instrumentation-library: dbmon logs_endpoint: https://ingest.your-splunk-realm.observability.splunkcloud.com/v3/event sending_queue: batch: flush_timeout: 15s max_size: 10485760 sizer: bytes -
In the
service.pipelines:section, create a metrics pipeline namedmetrics/dbmonand a logs pipeline namedlogs/dbmon:YAMLmetrics/dbmon: receivers: - mysql processors: - memory_limiter - batch - resourcedetection - resource/mysql_service_instance_id exporters: - signalfx logs/dbmon: receivers: - mysql processors: - memory_limiter - batch - resource/mysql_service_instance_id exporters: - otlp_http/dbmon -
Restart the collector to apply your configuration changes.
The restart command varies depending on what platform you deployed the collector on and what tool you used to deploy it. Here are general examples of the restart command:
- Linux
-
BASH
sudo systemctl restart splunk-otel-collector - Windows
-
Windows with installer script:
BASHstop-service splunk-otel-collector start-service splunk-otel-collector - Kubernetes
-
BASH
helm upgrade your-splunk-otel-collector splunk-otel-collector-chart/splunk-otel-collector -f your-override-values.yamlwhere
splunk-otel-collector-chartis the name you gave to the Helm chart in thehelm repo addcommand.
Your database instance should now be visible on as well as on if you have a Database Monitoring license. For troubleshooting, see Troubleshoot data collection .
Advanced configurations
- Collect data from multiple MySQL or MariaDB instances
-
Omit the database name parameter,
receivers.mysql.database. If omitted, the receiver will monitor all databases in the configured instance. - Authenticate to Amazon RDS or Aurora with AWS IAM
-
By default, the receiver authenticates with the
passwordsetting. On Amazon RDS for MySQL, Amazon Aurora MySQL, and Amazon RDS for MariaDB, you can use AWS IAM database authentication instead. With IAM authentication, the collector creates a short-lived authentication token for each database connection instead of storing a database password in the collector configuration.Note: AWS IAM database authentication requires Splunk Distribution of the OpenTelemetry Collector (splunk-otel-collector) version 0.161.0 or higher, or Community (OSS) version of the OpenTelemetry Collector (opentelemetry-collector-contrib) version 0.161.0 or higher.Before you configure the receiver, complete the AWS and database prerequisites. For AWS setup instructions, see IAM database authentication for MariaDB, MySQL, and PostgreSQL in the Amazon RDS User Guide. At minimum, activate IAM database authentication, create a database user with
AWSAuthenticationPlugin, require SSL, and attach an IAM policy that grantsrds-db:connectto the IAM role that runs the collector.IAM authentication has two configuration parts:
- The
aws_iam_db_authextension, which stores the AWS Region and creates tokens. - The
db_authreceiver setting, which points to the extension by its component ID.
Configure IAM authentication in the collector:
- In the
extensions:section, addaws_iam_db_authand setregionto the AWS Region of your database. Theregionsetting is required. - In the
receivers:section, setdb_authtoaws_iam_db_authand remove thepasswordsetting. Keepusername. The receiver passes the user name to the extension so the extension can create the token. - Set
tls.insecuretofalse. IAM database authentication requires an encrypted connection. - In the
service.extensions:section, addaws_iam_db_authto the existing list of extensions.
For example:
YAMLextensions: aws_iam_db_auth: region: us-east-1 receivers: mysql: collection_interval: 10s endpoint: your-service-endpoint:3306 username: otel-user db_auth: aws_iam_db_auth events: db.server.query_sample: enabled: true db.server.top_query: enabled: true resource_attributes: mysql.instance.endpoint: enabled: true tls: insecure: false insecure_skip_verify: false ca_file: /etc/ssl/certs/rds-global-bundle.pem service: extensions: - aws_iam_db_auth pipelines: metrics/dbmon: receivers: - mysql processors: - memory_limiter - batch - resourcedetection - resource/mysql_service_instance_id exporters: - signalfxImportant:db_authandpasswordare mutually exclusive. If you set both, the collector fails to start withinvalid config: set either 'password' or 'db_auth', not both. Removepasswordwhen you usedb_auth.Note: Theservice.extensionslist in the example is abbreviated. Addaws_iam_db_authto the extensions that your configuration already declares. An extension that is configured but missing fromservice.extensionsdoesn't start, and the receiver fails withdb_auth: requested credential provider is not present.Configure TLS for IAM authentication. AWS requires an SSL or TLS connection because the MySQL driver sends the IAM token by using the MySQL cleartext password plugin.
tlssettingTLS behavior IAM authentication support insecure: true, ortlsomittedNo TLS Not supported insecure: falseandinsecure_skip_verify: trueTLS without server certificate verification Supported insecure: falseandinsecure_skip_verify: falseTLS with server certificate verification Supported and recommended AWS recommends verifying the server certificate with the Amazon RDS certificate bundle. Set
insecure_skip_verify: falseand pointca_fileat the certificate bundle. To download the bundle, see Using SSL/TLS to encrypt a connection to a DB instance or cluster in the Amazon RDS User Guide.The sample in Configure the receiver omits
tls. Omittingtlsis equivalent toinsecure: trueand isn't compatible with IAM authentication.To monitor databases in more than one AWS Region, declare one named instance of the extension for each Region and point each receiver to the extension instance it needs:
YAMLextensions: aws_iam_db_auth: region: us-east-1 aws_iam_db_auth/west: region: us-west-2 receivers: mysql/east: endpoint: east-db.example.com:3306 username: otel-user db_auth: aws_iam_db_auth tls: insecure: false mysql/west: endpoint: west-db.example.com:3306 username: otel-user db_auth: aws_iam_db_auth/west tls: insecure: false service: extensions: - aws_iam_db_auth - aws_iam_db_auth/westDatabases in the same AWS Region can share one extension instance. To add another database in the same Region, add another receiver with the same
db_authvalue.Tip:Authentication token lifecycle
AWS IAM database authentication tokens have a 15-minute validity window. The collector requests a new token when it opens a database connection, so you don't need to restart the collector to renew tokens. IAM authenticates when a connection opens, not for each query, so established connections remain valid for their lifetime.
Use the following table to troubleshoot AWS IAM authentication errors:
Message in the collector log Cause and resolution invalid config: set either 'password' or 'db_auth', not bothBoth credential settings are present. Remove password.invalid config: 'db_auth' requires TLS; set 'tls.insecure' to falsetlsis omitted ortls.insecureistrue. Settls.insecure: false.db_auth: requested credential provider is not present: "aws_iam_db_auth"The extension is configured but isn't listed in service.extensions. Add it.db_auth: requested extension is not a credential providerdb_authnames an extension that doesn't provide database credentials. Set it to anaws_iam_db_authinstance.aws_iam_db_auth: region must be set on the extensionAdd the required regionsetting to the extension.aws_iam_db_auth: mint RDS token for ...The collector can't resolve AWS credentials. Confirm that the instance profile, task role, or IAM role for service accounts (IRSA) is attached and reachable. Access denied for user or an AWSAuthenticationPluginormysql_clear_passwordplugin errorThe AWS or database-user setup is incomplete. Confirm that IAM database authentication is active, the database user uses AWSAuthenticationPlugin, the IAM policy allowsrds-db:connectfor the exact user name, and the extension Region matches the database Region.An SSL or TLS connection error, or an error that says insecure transport isn't allowed TLS isn't established. Set tls.insecuretofalseand, if the server requires a verified CA, setca_fileto the Amazon RDS certificate bundle. - The
- Enable optional metrics
-
Set
metrics.metric-name.enabledtotrue. For example, for the optional metricsmysql.commands,mysql.connection.count, andmysql.connection.errors:YAMLmysql/extra_metrics: endpoint: host:port username: otel-user password: ${env:MYSQL_PASSWORD} database: mysql-database-name collection_interval: 10s mysql.commands: enabled: true mysql.connection.count: enabled: true mysql.connection.errors: enabled: true - TLS
-
Set these parameters at a minimum:
YAMLmysql/default_tls: endpoint: host:port username: otel-user password: ${env:MYSQL_PASSWORD} database: mysql-database-name collection_interval: 10s tls: server_name_override: localhost
Set up APM correlation
Settings reference
Configuration options for this receiver:
included
https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/receiver/mysql.yaml
Metrics reference
Metrics, attributes, and resource attributes reported by this receiver:
included
https://raw.githubusercontent.com/splunk/collector-config-tools/main/metric-metadata/mysqlreceiver.yaml