Today, we are excited to announce that the MySQL integration has received an important update, which includes a new pre-built MySQL logs dashboard and the Grafana Agent configuration to view and collect MySQL server logs.
The integration is already available in Grafana Cloud, our platform that brings together all your metrics, logs, and traces with Grafana for full-stack observability.
Why you need logs
Of all the three pillars of observability, metrics are the most widely used: They are easier to gather and store than logs or traces. They are great for detecting problems and understanding system performance at a glance. Still, metrics are often not enough to understand what caused an issue.
On the other hand, logs can tell you many more details about the root cause, once you narrow down the time and location of the problem using metrics.
Getting started with the MySQL integration
Grafana Agent is the universal collector and is all you need to send different telemetry data to the Grafana Cloud stack, including metrics, logs, and traces.
If you already use the embedded Agent integration to collect Prometheus metrics, your Agent configuration could look like this:
integrations: prometheus_remote_write: - url: https://<cloud-endpoint>/api/prom/push mysqld_exporter: enabled: true instance: mysql-01 data_source_name: "root:put-password-here@(localhost:3306)/"
Adding MySQL logs is just adding some extra lines of Grafana Agent config.yml:
metrics: wal_directory: /tmp/wal logs: configs: - name: agent clients: - url: https://<cloud-logs-endpoint>/loki/api/v1/push positions: filename: /tmp/positions.yaml target_config: sync_period: 10s scrape_configs: - job_name: integrations/mysql static_configs: - labels: instance: mysql-01 job: integrations/mysql __path__: /var/log/mysql/*.log pipeline_stages: - regex: expression: '(?P<timestamp>.+) (?P<thread>[\d]+) \[(?P<label>.+?)\]( \[(?P<err_code>.+?)\] \[(?P<subsystem>.+?)\])? (?P<msg>.+)' - labels: label: err_code: subsystem: - drop: expression: "^ *$" drop_counter_reason: "drop empty lines" integrations: prometheus_remote_write: - url: https://<cloud-endpoint>/api/prom/push mysqld_exporter: enabled: true instance: mysql-01 data_source_name: "root:put-password-here@(localhost:3306)/" relabel_configs: - source_labels: [__address__] target_label: job replacement: 'integrations/mysql'
The additional configuration above locates and parses MySQL server logs by using an embedded Promtail Agent.
The most crucial configuration part is to make sure that the labels
instance match each other for logs and metrics. This ensures that we can quickly dive from graphs to corresponding logs for more details on what actually happened.
You can find more information on configuring the MySQL integration in our MySQL integration documentation.
To learn more and get a better understanding of how to correlate metrics, logs, and traces in Grafana, I also recommend checking out the detailed talk by Andrej Ocenas on how to successfully correlate metrics, logs, and traces in Grafana.
Start monitoring with the MySQL logs dashboard
Along with coming packaged with pre-built dashboards as well as metrics and alerts, the MySQL integration for Grafana Cloud now bundles a new MySQL logs dashboard that can be quickly accessed from the MySQL overview dashboard when you need a deeper understanding of what’s going on with your MySQL server:
There’s supposed to be a video here, but for some reason there isn’t. Either we entered the id wrong (oops!), or Vimeo is down. If it’s the latter, we’d expect they’ll be back up and running soon. In the meantime, check out our blog!
The important thing to note is that if you jump from one dashboard to another, the context of the MySQL instance and time interval will remain the same.
Try out the MySQL integration
The enhanced MySQL integration with log capabilities is available now for Grafana Cloud users. If you’re not already using Grafana Cloud, we have a generous free forever tier and plans for every use case. Sign up for free now!
It’s the easiest way to get started observing metrics, logs, traces, and dashboards.
For more information on monitoring and alerting on Grafana Cloud and MySQL, check out our MySQL integration documentation, the MySQL solutions page, or join the #integrations channel in the Grafana Labs Community Slack.