Monitoring MySQL Logs with ClickStack
This guide shows you how to monitor MySQL with ClickStack by configuring the OpenTelemetry collector to ingest MySQL server logs. You'll learn how to:
- Configure MySQL to output error logs and slow query logs
- Create a custom OTel collector configuration for log ingestion
- Deploy ClickStack with your custom configuration
- Use a pre-built dashboard to visualize MySQL log insights (errors, slow queries, connections)
A demo dataset with sample logs is available if you want to test the integration before configuring your production MySQL.
Time Required: 10-15 minutes
Integration with existing MySQL
This section covers configuring your existing MySQL installation to send logs to ClickStack by modifying the ClickStack OTel collector configuration.
If you would like to test the MySQL logs integration before configuring your own existing setup, you can test with our preconfigured setup and sample data in the "Demo dataset" section.
Prerequisites
- ClickStack instance running
- Existing MySQL installation (version 5.7 or newer)
- Access to modify MySQL configuration files
- Sufficient disk space for log files
Configure MySQL logging
MySQL supports multiple log types. For comprehensive monitoring with OpenTelemetry, we recommend enabling the error log and slow query log.
The my.cnf or my.ini configuration file is typically located at:
- Linux (apt/yum):
/etc/mysql/my.cnfor/etc/my.cnf - macOS (Homebrew):
/usr/local/etc/my.cnfor/opt/homebrew/etc/my.cnf - Docker: Configuration is usually set via environment variables or mounted config file
Add or modify these settings in the [mysqld] section:
The slow query log captures queries that take longer than long_query_time seconds. Adjust this threshold based on your application's performance requirements. Setting it too low will generate excessive logs.
After making these changes, restart MySQL:
Verify logs are being written:
Create custom OTel collector configuration
ClickStack allows you to extend the base OpenTelemetry Collector configuration by mounting a custom configuration file and setting an environment variable. The custom configuration is merged with the base configuration managed by HyperDX via OpAMP.
Create a file named mysql-logs-monitoring.yaml with the following configuration:
This configuration:
- Reads MySQL error logs and slow query logs from their standard locations
- Handles multi-line log entries (slow queries span multiple lines)
- Parses both log formats to extract structured fields (level, error_code, query_time, rows_examined)
- Preserves original log timestamps
- Adds
source: mysql-errorandsource: mysql-slowattributes for filtering in HyperDX - Routes logs to the ClickHouse exporter via a dedicated pipeline
Two receivers are required because MySQL error logs and slow query logs have completely different formats. The time_parser uses gotime layout to handle MySQL's ISO8601 timestamp format with timezone offsets.
Configure ClickStack to load custom configuration
To enable custom collector configuration in your existing ClickStack deployment, mount the custom config file at /etc/otelcol-contrib/custom.config.yaml and set the environment variable CUSTOM_OTELCOL_CONFIG_FILE=/etc/otelcol-contrib/custom.config.yaml.
Update your ClickStack deployment configuration:
Ensure the ClickStack collector has appropriate permissions to read the MySQL log files. Use read-only mounts (:ro) and follow the principle of least privilege.
Verifying Logs in HyperDX
Once configured, log into HyperDX and verify logs are flowing:
- Navigate to the search view
- Set source to Logs
- Filter by
source:mysql-errororsource:mysql-slowto see MySQL-specific logs - You should see structured log entries with fields like
level,error_code,message(for error logs) andquery_time,rows_examined,query(for slow query logs)
Demo dataset
For users who want to test the MySQL logs integration before configuring their production systems, we provide a sample dataset of pre-generated MySQL logs with realistic patterns.
Download the sample dataset
Download the sample log files:
The dataset includes:
- Error log entries (startup messages, warnings, connection errors, InnoDB messages)
- Slow queries with realistic performance characteristics
- Connection lifecycle events
- Database server startup and shutdown sequences
Create test collector configuration
Create a file named mysql-logs-demo.yaml with the following configuration:
Verify logs in HyperDX
Once ClickStack is running:
- Wait a few moments for ClickStack to fully initialize (typically 30-60 seconds)
- Open HyperDX and log in to your account (you may need to create an account first)
- Navigate to the Search view and set the source to
Logs - Set the time range to 2025-11-13 00:00:00 - 2025-11-16 00:00:00
- You should see 40 logs total (30 error logs with
source:mysql-demo-error+ 10 slow queries withsource:mysql-demo-slow)
If you don't see all 40 logs immediately, wait about a minute for the collector to finish processing. If logs still don't appear after waiting, run docker restart clickstack-demo and check again after another minute. This is a known issue with the OpenTelemetry filelog receiver when bulk-loading pre-existing files with start_at: beginning. Production deployments using start_at: end process logs as they're written in real-time and don't experience this issue.
HyperDX displays timestamps in your browser's local timezone. The demo data spans 2025-11-14 00:00:00 - 2025-11-15 00:00:00 (UTC). The wide time range ensures you'll see the demo logs regardless of your location. Once you see the logs, you can narrow the range to a 24-hour period for clearer visualizations.
Dashboards and visualization
To help you get started monitoring MySQL with ClickStack, we provide essential visualizations for MySQL logs.
Import the pre-built dashboard
- Open HyperDX and navigate to the Dashboards section
- Click Import Dashboard in the upper right corner under the ellipses
- Upload the
mysql-logs-dashboard.jsonfile and click Finish Import
View the dashboard
The dashboard will be created with all visualizations pre-configured.
For the demo dataset, set the time range to 2025-11-14 00:00:00 - 2025-11-15 00:00:00 (UTC) (adjust based on your local timezone). The imported dashboard will not have a time range specified by default.
Troubleshooting
Custom config not loading
Verify the environment variable is set:
Check the custom config file is mounted and readable:
No logs appearing in HyperDX
Check the effective config includes your filelog receiver:
Check for errors in the collector logs:
If using the demo dataset, verify the log files are accessible:
Slow query logs not appearing
Verify slow query log is enabled in MySQL:
Check if MySQL is writing slow queries:
Generate a test slow query:
Logs not parsing correctly
Verify your MySQL log format matches the expected format. The regex patterns in this guide are designed for MySQL 5.7+ and 8.0+ default formats.
Check a few lines from your error log:
Expected format:
If your format differs significantly, adjust the regex patterns in the configuration.
Next steps
After setting up MySQL logs monitoring:
- Set up alerts for critical events (connection failures, slow queries exceeding thresholds, error spikes)
- Create custom dashboards for slow query analysis by query pattern
- Tune
long_query_timebased on observed query performance patterns
Going to production
This guide extends ClickStack's built-in OpenTelemetry Collector for quick setup. For production deployments, we recommend running your own OTel Collector and sending data to ClickStack's OTLP endpoint. See Sending OpenTelemetry data for production configuration.