Skip to main content

 

Splunk Lantern

Monitoring MariaDB and MySQL with Observability Cloud

 

This article outlines how to monitor MariaDB and MySQL to ensure the performance, health, and resilience of database systems that support business applications.

  • The example shown in this article uses MariaDB, but the same approach and receiver works for both MariaDB and MySQL.
  • For additional insights, refer to Monitoring PostgreSQL, which covers best practices for database performance monitoring.

Get metrics from MariaDB into Observability Cloud

To collect metrics from MariaDB or MySQL and send them to Splunk Observability Cloud, you'll need to instrument the backend service connected to the database.

Install and configure the OpenTelemetry Collector

Follow these steps to install and configure the OpenTelemetry Collector:

  1. Download and install the Splunk Distribution of the OpenTelemetry Collector.
  2. Refer to the guided installation documentation for detailed setup instructions.
  3. Use Docker Compose to set up an application, MariaDB service, and the Splunk Distribution of the OpenTelemetry Collector.

clipboard_e634de3c18b7fd03a7b852ba2f79f63e3.png

Next, configure the OpenTelemetry Collector with a receiver to collect telemetry data from MariaDB and export it to Splunk Observability Cloud.

  1. Make the following configurations in your existing OpenTelemetry Collector configuration file, or create an empty otel-collector-config.yaml file if you don't already have one.
    1. Define the MariaDB-compatible mysql receiver under the receivers block.
    2. Add the Splunk Observability Cloud exporter under the exporters block.
    3. Ensure that the receivers and exporters are included in the service pipelines.

clipboard_eae308eb5ad50f480b51eba2125b7d644.png

Visualizing the data in Splunk Observability Cloud

With the OpenTelemetry Collector installed and configured, database performance can be monitored within Splunk Observability Cloud. From Splunk Application Performance Monitoring you can view all of your application services and get a comprehensive performance overview, including performance details around your MariaDB.

  1. Navigate to Application Performance Monitoring (APM).
  2. Locate the MariaDB instance in the service overview.

clipboard_e548d50e704019ec025317a26810095d4.png

You can explore your Service Map to visualize your MariaDB instance and how it fits in with the other services in your application.

clipboard_e334c5d35e372e47d6a618bd08c4fcde4.png

Select your MariaDB instance to get deeper insight into performance metrics, requests, and errors.

clipboard_e3c0f4611ac3ad7923c0d2feace7e4499.png

Scroll down in the Breakdown dropdown results on the right side of the screen to view Database query performance, showing you how specific queries perform and which queries are being run.

clipboard_e1e5cd42f43e82f51348e4c48cac5afbb.png

Clicking into Database Query Performance takes you to a view that you can sort by total query response time, queries in the 90th percentile of latency, or total requests. This lets you can quickly isolate queries that might be impacting your services and your users.

clipboard_e4dabeb896056ed784bb3c50496cc89fd.png

You can select specific queries from your Top Queries for more query detail, like the full query, requests and errors, latency, and query tags.

clipboard_e73f8a1897c06978d7add6f85f2fc5898.png

clipboard_e1940fdc500062ab1aff54d48fabfe6e4.png

You can explore specific traces related to high-latency database requests, letting you see how specific users were affected by database performance.

clipboard_ea1bd4bc98317575b9336fdea4506b86c.png

You can view span performance.

clipboard_e9ce08c10ad0db0d29a82cd724bb9b031.png

Finally, you can see the db.statement for the trace.

clipboard_ece9dc70490d297e3e4cad61a752ff81e.png

You can proactively use this information to further optimize your queries and improve user experience. You can also see that the database activity shows up in the overall trace waterfall, letting you get a full picture of how all components of the stack were involved in this transaction.

Using monitoring data during an incident

During incidents, database monitoring data becomes critical for troubleshooting. If database errors occur:

  1. Open the Service Map to check for errors.
  2. Look for issues highlighted in red.

    clipboard_ec0f0fdf84e70a6d220d82a78c33b1ba8.png

  3. Investigate traces related to error spikes.

    clipboard_e04628f76d02d72426af4005fe7f54e66.png

The stacktrace helps you get to the root cause of errors. In this case, an improperly specified connection string was causing an issue, and you can see the exact line where an exception was thrown.

clipboard_e614f71a431f6ff68038ae0d8c0237042.png

With quick, at-a-glance insight into service and database issues, you can easily jump into the code, restore your database connection issue, and get your service back up and running so your users can carry on enjoying your application.

Next steps

Monitoring MariaDB is essential for database performance, reliability, and user experience. By integrating the OpenTelemetry Collector with Splunk Observability Cloud, database telemetry data can be visualized, analyzed, and used proactively to detect and resolve performance issues.

These resources might help you understand and implement this guidance: