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
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 - 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'@'%'; FLUSH PRIVILEGES; - 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:On AWS RDS, you can grant
EXECUTEonmysql.rds_versionto suppress collector log warnings.SQLGRANT EXECUTE ON PROCEDURE mysql.rds_version TO 'otel-user'@'%'; -
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: trueImportant: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./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. - 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